A C++ template library for embedded applications
MIT licensed
Designed and
maintained by
John Wellbelove
Support the development
of the ETL
utility.h

Utility


A few useful utility functions and classes.

____________________________________________________________________________________________________
pair
template <typename T1, typename T2>
struct pair
A clone of std::pair

C++03
template <typename T1, typename T2>
pair<T1, T2> make_pair(T1 a, T2 b)

C++11 and above
template <typename T1, typename T2>
pair<T1, T2> make_pair(T1&& a, T2&& b)
Returns a pair.
____________________________________________________________________________________________________
Template deduction guides
C++17 and above

template <typename T1, typename T2>
pair(T1, T2) ->pair<T1, T2>;
____________________________________________________________________________________________________
exchange

template <typename T, typename U = T>
T exchange(T& object, const U& new_value)
Copies the new value to object and returns the old value.
Note: This is not an atomic operation.
__________________________________________________________________________________________________
add_const

template <typename T>
typename etl::add_const<T>::type& as_const(T& t)
Returns a value of type T as a const T.
__________________________________________________________________________________________________
functor
For C++11 and above.

template <typename TReturn, typename... TParams>
class functor
Wraps a free/global function in a functor.
____________________________________________________________________________________________________
constexpr functor(TReturn(*ptr_)(TParams...))
Constructs a functor from a function pointer.
____________________________________________________________________________________________________
TReturn operator()(TParams... args)
Function operator.
Calls the wrapped function with the forwarded parameters.
____________________________________________________________________________________________________
TReturn operator()(TParams... args) const
Function operator.
Calls the wrapped function with the forwarded parameters.
__________________________________________________________________________________________________
integer_sequence
20.14.0

template <typename T, T... Integers>
class integer_sequence
__________________________________________________________________________________________________
index_sequence
20.14.0

template <size_t... Indices>
using index_sequence = etl::integer_sequence<size_t, Indices...>;

template <size_t N>
make_index_sequence