Simple traits for container classes.Trait classes describing a type have a type
member defined after that type. They are also available as template types, in the fashion of C++14.
More...
Classes | |
struct | util::collection_value_type< Coll > |
Trait of value contained in the template collection Coll . More... | |
struct | util::collection_value_access_type< Coll > |
Trait of type obtained by access to element of collection Coll . More... | |
struct | util::collection_value_constant_access_type< Coll > |
Trait of type obtained by constant access to element of collection Coll . More... | |
struct | util::collection_reference_type< Coll > |
Trait of a type that can be used to reference the collection Coll . More... | |
struct | util::collection_from_reference_type< CollRef > |
Trait with the type of collection referenced by collRef . More... | |
Typedefs | |
template<typename Coll > | |
using | util::collection_value_t = typename collection_value_type< Coll >::type |
Type contained in the collection Coll . More... | |
template<typename Coll > | |
using | util::collection_value_access_t = typename collection_value_access_type< Coll >::type |
Type obtained by constant access to element of collection Coll . More... | |
template<typename Coll > | |
using | util::collection_value_constant_access_t = typename collection_value_constant_access_type< Coll >::type |
Type obtained by constant access to element of collection Coll . More... | |
template<typename Coll > | |
using | util::collection_reference_t = typename collection_reference_type< Coll >::type |
The type contained in util::collection_reference_type trait. More... | |
template<typename Cont > | |
using | util::collection_from_reference_t = typename collection_from_reference_type< Cont >::type |
Type contained in util::collection_from_reference_type trait. More... | |
Functions | |
template<typename Coll > | |
auto | util::make_collection_reference (Coll &&coll) |
Returns an object referencing to the data contained in coll . More... | |
template<typename CollRef > | |
decltype(auto) | util::collection_from_reference (CollRef &collRef) |
Returns the object referenced by collRef as a C++ reference. More... | |
Simple traits for container classes.
Trait classes describing a type have a type
member defined after that type. They are also available as template types, in the fashion of C++14.
Trait classes describing a value have a value
member (static, constexpr) defined with that value. They are also available as template constants, in the fashion of C++17.
Container classes mimicking the C++ STL interface provide a value_type
type detailing the contained object. This is generalised in the util::collection_value_type
trait, which can be specialised for containers which do not support that.
Two additional traits are provided, which describe the type obtained by accessing an element of the container. This is a close relative of util::collection_value_type
, but it may be decorated by l-value reference or constantness depending on the container. The two traits represent access one to a container that is mutable, the other to one that is constant.
using util::collection_from_reference_t = typedef typename collection_from_reference_type<Cont>::type |
Type contained in util::collection_from_reference_type
trait.
Definition at line 149 of file ContainerMeta.h.
using util::collection_reference_t = typedef typename collection_reference_type<Coll>::type |
The type contained in util::collection_reference_type
trait.
Definition at line 110 of file ContainerMeta.h.
using util::collection_value_access_t = typedef typename collection_value_access_type<Coll>::type |
Type obtained by constant access to element of collection Coll
.
Definition at line 76 of file ContainerMeta.h.
using util::collection_value_constant_access_t = typedef typename collection_value_constant_access_type<Coll>::type |
Type obtained by constant access to element of collection Coll
.
Definition at line 87 of file ContainerMeta.h.
using util::collection_value_t = typedef typename collection_value_type<Coll>::type |
Type contained in the collection Coll
.
Definition at line 65 of file ContainerMeta.h.
decltype(auto) util::collection_from_reference | ( | CollRef & | collRef | ) |
Returns the object referenced by collRef
as a C++ reference.
CollRef | type of collection of the data |
collRef | collection of the data to be referenced to |
collRef
The return value is a direct reference to the unwrapped container collRef
. For example, a collRef
of type std::reference_wrapper
will result in a C reference of the wrapped container, while a C pointer is left unchanged and a std::unique_ptr
object is turned into the equivalent pointer to its elements.
Definition at line 427 of file ContainerMeta.h.
auto util::make_collection_reference | ( | Coll && | coll | ) |
Returns an object referencing to the data contained in coll
.
Coll | type of collection of the data |
coll
The criteria, as well as the type of the returned object, are similar to util::collection_reference_type
. Therefore, for example a C pointer is returned unchanged, while a std::vector
is returned wrapped into a std::reference_wrapper
. A std::unique_ptr
is returned as bare pointer, given that the returned object does not own the data.
Definition at line 413 of file ContainerMeta.h.