distortos
v0.7.0
object-oriented C++ RTOS for microcontrollers
|
Collection of useful templates. More...
Namespaces | |
internal | |
Internals of estd namespace - should not be used directly! | |
Classes | |
class | ContiguousRange |
ContiguousRange template class is a pair of iterators to contiguous sequence of elements in memory. More... | |
class | IntegerSequence |
Compile-time sequence of integers. More... | |
class | IntrusiveForwardList |
IntrusiveForwardList class is an intrusive linear singly linked list. More... | |
class | IntrusiveForwardListConstIterator |
IntrusiveForwardListConstIterator class is a const iterator of elements on IntrusiveForwardList. More... | |
class | IntrusiveForwardListIterator |
IntrusiveForwardListIterator class is an iterator of elements on IntrusiveForwardList. More... | |
class | IntrusiveForwardListNode |
IntrusiveForwardListNode class is the node that is needed for the object to be linked in IntrusiveForwardList. More... | |
class | IntrusiveList |
IntrusiveList class is an intrusive circular doubly linked list. More... | |
class | IntrusiveListConstIterator |
IntrusiveListConstIterator class is a const iterator of elements on IntrusiveList. More... | |
class | IntrusiveListIterator |
IntrusiveListIterator class is an iterator of elements on IntrusiveList. More... | |
class | IntrusiveListNode |
IntrusiveListNode class is the node that is needed for the object to be linked in IntrusiveList. More... | |
struct | isEnumClassFlags |
Tag struct used to enable bitwise operators for selected enum class flags. More... | |
struct | isEnumClassFlags< distortos::chip::DmaChannelFlags > |
Enable bitwise operators for distortos::chip::DmaChannelFlags. More... | |
struct | isEnumClassFlags< distortos::devices::R1ResponseErrors > |
Enable bitwise operators for distortos::devices::R1ResponseErrors. More... | |
class | ReferenceHolder |
ReferenceHolder template class is a ROMable holder of a reference. More... | |
class | ReverseAdaptor |
ReverseAdaptor template class is an adaptor that "reverses" access to the container. More... | |
class | ScopeGuard |
ScopeGuard template class is a idiom introduced by Andrei Alexandrescu and proposed for C++14 in N3949. More... | |
class | SortedIntrusiveForwardList |
SortedIntrusiveForwardList class is an IntrusiveForwardList with sorted elements. More... | |
class | SortedIntrusiveList |
SortedIntrusiveList class is an IntrusiveList with sorted elements. More... | |
class | TypeErasedFunctor |
class | TypeErasedFunctor< R(Args...), false > |
TypeErasedFunctor class is an interface for type-erased functors. More... | |
class | TypeErasedFunctor< R(Args...), true > |
TypeErasedFunctor class is an interface for type-erased functors. More... | |
Typedefs | |
template<std::size_t... Indexes> | |
using | IndexSequence = IntegerSequence< std::size_t, Indexes... > |
Compile-time sequence of std::size_t elements. More... | |
template<typename T , T N> | |
using | MakeIntegerSequence = typename internal::MakeIntegerSequenceImplementationWrapper< T, N >::type::base |
Generator of IntegerSequence types. More... | |
template<std::size_t N> | |
using | MakeIndexSequence = MakeIntegerSequence< std::size_t, N > |
Generator of IndexSequence types. More... | |
template<typename... T> | |
using | IndexSequenceFor = MakeIndexSequence< sizeof...(T)> |
Generator of IndexSequence types. More... | |
template<size_t size> | |
using | TypeFromSize = typename internal::TypeFromSize< size >::Type |
Selects fixed width type from requested byte size. More... | |
Functions | |
template<typename Function , typename Tuple > | |
constexpr auto | apply (Function &&function, Tuple &&tuple) -> decltype(internal::apply(std::forward< Function >(function), std::forward< Tuple >(tuple), estd::MakeIndexSequence< std::tuple_size< typename std::decay< Tuple >::type > |
Invokes callable object with a tuple of arguments. More... | |
template<size_t index, size_t size, bool reverse = {}, typename Ret = TypeFromSize<(size + CHAR_BIT - 1) / CHAR_BIT>, typename T , size_t arraySize> | |
static Ret | extractBitField (const std::array< T, arraySize > &array) |
Extracts a bit field from array of raw data. More... | |
void | swap (IntrusiveForwardListNode &left, IntrusiveForwardListNode &right) |
Swaps contents of two nodes. More... | |
template<typename T , IntrusiveForwardListNode T::* NodePointer, typename U = T> | |
bool | operator!= (const IntrusiveForwardListIterator< T, NodePointer, U > &left, const IntrusiveForwardListIterator< T, NodePointer, U > &right) |
IntrusiveForwardListIterator's "not equal to" comparison operator. More... | |
template<typename T , const IntrusiveForwardListNode T::* NodePointer, typename U = T> | |
bool | operator!= (const IntrusiveForwardListConstIterator< T, NodePointer, U > &left, const IntrusiveForwardListConstIterator< T, NodePointer, U > &right) |
IntrusiveForwardListConstIterator's "not equal to" comparison operator. More... | |
template<typename T , IntrusiveForwardListNode T::* NodePointer, const IntrusiveForwardListNode T::* ConstNodePointer, typename U = T> | |
bool | operator== (const IntrusiveForwardListIterator< T, NodePointer, U > &left, const IntrusiveForwardListConstIterator< T, ConstNodePointer, U > &right) |
"Equal to" comparison operator for IntrusiveForwardListIterator and IntrusiveForwardListConstIterator More... | |
template<typename T , IntrusiveForwardListNode T::* NodePointer, const IntrusiveForwardListNode T::* ConstNodePointer, typename U = T> | |
bool | operator!= (const IntrusiveForwardListIterator< T, NodePointer, U > &left, const IntrusiveForwardListConstIterator< T, ConstNodePointer, U > &right) |
"Not equal to" comparison operator for IntrusiveForwardListIterator and IntrusiveForwardListConstIterator More... | |
template<typename T , IntrusiveForwardListNode T::* NodePointer, const IntrusiveForwardListNode T::* ConstNodePointer, typename U = T> | |
bool | operator!= (const IntrusiveForwardListConstIterator< T, ConstNodePointer, U > &left, const IntrusiveForwardListIterator< T, NodePointer, U > &right) |
"Not equal to" comparison operator for IntrusiveForwardListConstIterator and IntrusiveForwardListIterator More... | |
template<typename T , IntrusiveForwardListNode T::* NodePointer, typename U = T> | |
void | swap (IntrusiveForwardList< T, NodePointer, U > &left, IntrusiveForwardList< T, NodePointer, U > &right) |
Swaps contents of two lists. More... | |
template<typename T , IntrusiveListNode T::* NodePointer, typename U = T> | |
bool | operator!= (const IntrusiveListIterator< T, NodePointer, U > &left, const IntrusiveListIterator< T, NodePointer, U > &right) |
IntrusiveListIterator's "not equal to" comparison operator. More... | |
template<typename T , const IntrusiveListNode T::* NodePointer, typename U = T> | |
bool | operator!= (const IntrusiveListConstIterator< T, NodePointer, U > &left, const IntrusiveListConstIterator< T, NodePointer, U > &right) |
IntrusiveListConstIterator's "not equal to" comparison operator. More... | |
template<typename T , IntrusiveListNode T::* NodePointer, const IntrusiveListNode T::* ConstNodePointer, typename U = T> | |
bool | operator== (const IntrusiveListIterator< T, NodePointer, U > &left, const IntrusiveListConstIterator< T, ConstNodePointer, U > &right) |
"Equal to" comparison operator for IntrusiveListIterator and IntrusiveListConstIterator More... | |
template<typename T , IntrusiveListNode T::* NodePointer, const IntrusiveListNode T::* ConstNodePointer, typename U = T> | |
bool | operator!= (const IntrusiveListIterator< T, NodePointer, U > &left, const IntrusiveListConstIterator< T, ConstNodePointer, U > &right) |
"Not equal to" comparison operator for IntrusiveListIterator and IntrusiveListConstIterator More... | |
template<typename T , IntrusiveListNode T::* NodePointer, const IntrusiveListNode T::* ConstNodePointer, typename U = T> | |
bool | operator!= (const IntrusiveListConstIterator< T, ConstNodePointer, U > &left, const IntrusiveListIterator< T, NodePointer, U > &right) |
"Not equal to" comparison operator for IntrusiveListConstIterator and IntrusiveListIterator More... | |
template<typename T , IntrusiveListNode T::* NodePointer, typename U = T> | |
void | swap (IntrusiveList< T, NodePointer, U > &left, IntrusiveList< T, NodePointer, U > &right) |
Swaps contents of two lists. More... | |
template<typename Function , typename... Args> | |
auto | invoke (Function &&function, Args &&... args) -> decltype(internal::invoke(std::forward< Function >(function), std::forward< Args >(args)...)) |
Invokes callable object in an appropriate way. More... | |
constexpr int | log2u (const unsigned int value) |
log2()-like constexpr function for unsigned int . More... | |
STATIC_ASSERT (log2u(0)==0) | |
STATIC_ASSERT (log2u(1)==0) | |
STATIC_ASSERT (log2u(2)==1) | |
STATIC_ASSERT (log2u(4)==2) | |
STATIC_ASSERT (log2u(8)==3) | |
STATIC_ASSERT (log2u(15)==3) | |
STATIC_ASSERT (log2u(16)==4) | |
STATIC_ASSERT (log2u(17)==4) | |
STATIC_ASSERT (log2u(127)==6) | |
STATIC_ASSERT (log2u(128)==7) | |
STATIC_ASSERT (log2u(129)==7) | |
STATIC_ASSERT (log2u(UINT_MAX)==sizeof(UINT_MAX) *CHAR_BIT - 1) | |
template<typename T > | |
ReverseAdaptor< T > | makeReverseAdaptor (T &container) |
Helper factory function to make ReverseAdaptor object with deduced template arguments. More... | |
template<typename Function > | |
ScopeGuard< Function > | makeScopeGuard (Function &&function) noexcept |
Helper factory function to make ScopeGuard object with deduced template arguments. More... | |
template<typename Compare , typename T , IntrusiveForwardListNode T::* NodePointer, typename U = T> | |
void | swap (SortedIntrusiveForwardList< Compare, T, NodePointer, U > &left, SortedIntrusiveForwardList< Compare, T, NodePointer, U > &right) |
Swaps contents of two lists. More... | |
template<typename Compare , typename T , IntrusiveListNode T::* NodePointer, typename U = T> | |
void | swap (SortedIntrusiveList< Compare, T, NodePointer, U > &left, SortedIntrusiveList< Compare, T, NodePointer, U > &right) |
Swaps contents of two lists. More... | |
STATIC_ASSERT (std::is_same< TypeFromSize< 0 >, uint8_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 1 >, uint8_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 2 >, uint16_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 3 >, uint32_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 4 >, uint32_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 5 >, uint64_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 6 >, uint64_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 7 >, uint64_t >::value==true) | |
STATIC_ASSERT (std::is_same< TypeFromSize< 8 >, uint64_t >::value==true) | |
Collection of useful templates.
using estd::IndexSequence = typedef IntegerSequence<std::size_t, Indexes...> |
Compile-time sequence of std::size_t elements.
Similar to std::index_sequence from C++14 - http://en.cppreference.com/w/cpp/utility/integer_sequence
Indexes | is a non-type parameter pack representing the sequence |
using estd::IndexSequenceFor = typedef MakeIndexSequence<sizeof...(T)> |
Generator of IndexSequence types.
Similar to std::index_sequence_for from C++14 - http://en.cppreference.com/w/cpp/utility/integer_sequence
Generates IndexSequence<0, 1, ..., sizeof...(T) - 1> type.
T | is the type parameter pack for which an index sequence of the same length will be generated |
using estd::MakeIndexSequence = typedef MakeIntegerSequence<std::size_t, N> |
Generator of IndexSequence types.
Similar to std::make_index_sequence from C++14 - http://en.cppreference.com/w/cpp/utility/integer_sequence
Generates IndexSequence<0, 1, ..., N - 1> type.
N | is the requested number of elements in the sequence |
using estd::MakeIntegerSequence = typedef typename internal::MakeIntegerSequenceImplementationWrapper<T, N>::type::base |
Generator of IntegerSequence types.
Similar to std::make_integer_sequence from C++14 - http://en.cppreference.com/w/cpp/utility/integer_sequence
Whole implementation is based on code from http://stackoverflow.com/a/20101039/157344
Generates IntegerSequence<T, 0, 1, ..., N - 1> type.
T | is an integer type to use for the elements of the sequence |
N | is the requested number of elements in the sequence |
using estd::TypeFromSize = typedef typename internal::TypeFromSize<size>::Type |
Selects fixed width type from requested byte size.
size | is the expected size of type, bytes |
constexpr auto estd::apply | ( | Function && | function, |
Tuple && | tuple | ||
) | -> decltype(internal::apply(std::forward<Function>(function), std::forward<Tuple>(tuple), estd::MakeIndexSequence<std::tuple_size<typename std::decay<Tuple>::type> |
Invokes callable object with a tuple of arguments.
Implementation inspired by http://en.cppreference.com/w/cpp/experimental/apply
Function | is the function object that will be invoked |
Tuple | is the type of tuple of arguments |
[in] | function | is the function object that will be executed |
[in] | tuple | is the tuple of arguments |
|
inlinestatic |
Extracts a bit field from array of raw data.
index | is the index of starting bit |
size | is the size of bit field to extract, bits |
reverse | selects whether index 0 is MSB (false) or LSB (true), default - false |
Ret | is the type of returned value, default - fixed width type with at least size bits |
T | is the type of elements of array, default - deduced from argument |
arraySize | is the number of elements in array, default - deduced from argument |
[in] | array | is a reference to array with raw data from which the bit field will be extracted |
|
inline |
Invokes callable object in an appropriate way.
Implementation inspired by http://en.cppreference.com/w/cpp/utility/functional/invoke
Function | is the function object that will be executed |
Args | are the arguments for Function |
[in] | function | is the function object that will be executed |
[in] | args | are arguments for function |
constexpr int estd::log2u | ( | const unsigned int | value | ) |
log2()-like constexpr function for unsigned int
.
Returns 0 when passed 0.
[in] | value | is the value for which the log2() will be calculated |
ReverseAdaptor<T> estd::makeReverseAdaptor | ( | T & | container | ) |
Helper factory function to make ReverseAdaptor object with deduced template arguments.
T | is the type of container |
[in] | container | is a reference to container |
|
noexcept |
Helper factory function to make ScopeGuard object with deduced template arguments.
Function | is the type of function executed on scope exit |
[in] | function | is a rvalue reference to function executed on scope exit |
|
inline |
IntrusiveForwardListIterator's "not equal to" comparison operator.
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveForwardListIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveForwardListIterator on right-hand side of comparison operator |
|
inline |
IntrusiveListIterator's "not equal to" comparison operator.
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveListIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveListIterator on right-hand side of comparison operator |
|
inline |
IntrusiveForwardListConstIterator's "not equal to" comparison operator.
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a const pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveForwardListConstIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveForwardListConstIterator on right-hand side of comparison operator |
|
inline |
"Not equal to" comparison operator for IntrusiveForwardListIterator and IntrusiveForwardListConstIterator
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a pointer-to-member to IntrusiveForwardListNode variable in T |
ConstNodePointer | is a const pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveForwardListIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveForwardListConstIterator on right-hand side of comparison operator |
|
inline |
"Not equal to" comparison operator for IntrusiveForwardListConstIterator and IntrusiveForwardListIterator
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a pointer-to-member to IntrusiveForwardListNode variable in T |
ConstNodePointer | is a const pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveForwardListConstIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveForwardListIterator on right-hand side of comparison operator |
|
inline |
IntrusiveListConstIterator's "not equal to" comparison operator.
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a const pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveListConstIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveListConstIterator on right-hand side of comparison operator |
|
inline |
"Not equal to" comparison operator for IntrusiveListIterator and IntrusiveListConstIterator
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a pointer-to-member to IntrusiveListNode variable in T |
ConstNodePointer | is a const pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveListIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveListConstIterator on right-hand side of comparison operator |
|
inline |
"Not equal to" comparison operator for IntrusiveListConstIterator and IntrusiveListIterator
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a pointer-to-member to IntrusiveListNode variable in T |
ConstNodePointer | is a const pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveListConstIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveListIterator on right-hand side of comparison operator |
|
inline |
"Equal to" comparison operator for IntrusiveForwardListIterator and IntrusiveForwardListConstIterator
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a pointer-to-member to IntrusiveForwardListNode variable in T |
ConstNodePointer | is a const pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveForwardListIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveForwardListConstIterator on right-hand side of comparison operator |
|
inline |
"Equal to" comparison operator for IntrusiveListIterator and IntrusiveListConstIterator
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a pointer-to-member to IntrusiveListNode variable in T |
ConstNodePointer | is a const pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a const reference to IntrusiveListIterator on left-hand side of comparison operator |
[in] | right | is a const reference to IntrusiveListConstIterator on right-hand side of comparison operator |
|
inline |
Swaps contents of two nodes.
[in] | left | is a reference to IntrusiveForwardListNode with which contents of right will be swapped |
[in] | right | is a reference to IntrusiveForwardListNode with which contents of left will be swapped |
|
inline |
Swaps contents of two lists.
Compare | is a type of functor used for comparison, std::less results in descending order, std::greater - in ascending order |
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a reference to SortedIntrusiveForwardList with which contents of right will be swapped |
[in] | right | is a reference to SortedIntrusiveForwardList with which contents of left will be swapped |
|
inline |
Swaps contents of two lists.
Compare | is a type of functor used for comparison, std::less results in descending order, std::greater - in ascending order |
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a reference to SortedIntrusiveList with which contents of right will be swapped |
[in] | right | is a reference to SortedIntrusiveList with which contents of left will be swapped |
|
inline |
Swaps contents of two lists.
T | is the type that has the IntrusiveForwardListNode variable |
NodePointer | is a pointer-to-member to IntrusiveForwardListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a reference to IntrusiveForwardList with which contents of right will be swapped |
[in] | right | is a reference to IntrusiveForwardList with which contents of left will be swapped |
|
inline |
Swaps contents of two lists.
T | is the type that has the IntrusiveListNode variable |
NodePointer | is a pointer-to-member to IntrusiveListNode variable in T |
U | is the type that will be stored on the list; it can be different from T, but U* must be implicitly convertible to T* (so usually a type derived from T); default - T; |
[in] | left | is a reference to IntrusiveList with which contents of right will be swapped |
[in] | right | is a reference to IntrusiveList with which contents of left will be swapped |