Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Metaprogramming with tuples-of-types and the std::tuple
record.
The metaprogramming part of this header complements typelist.hpp and allows some additional manipulations on type sequences, especially to integrate with the Tuples provided by the standard library.
Definition in file tuple-helper.hpp.
#include "lib/meta/typelist.hpp"
#include "lib/meta/typelist-util.hpp"
#include "lib/meta/typeseq-util.hpp"
#include "lib/meta/variadic-helper.hpp"
#include "lib/meta/util.hpp"
#include <tuple>
Classes | |
class | BuildTupleAccessor< _X_, TYPES, TUP, i > |
Decorating a tuple type with auxiliary data access operations. More... | |
class | BuildTupleAccessor< _X_, Types<>, TUP, i > |
struct | BuildTupleType< SEQ > |
struct | BuildTupleType< Node< H, TAIL > > |
struct | BuildTupleType< NullType > |
struct | BuildTupleType< Types< TYPES... > > |
temporary workaround: strip trailing NullType entries prior to rebinding to the std::tuple type. More... | |
struct | BuildTupleType< TySeq< TYPES... > > |
struct | ElementExtractor< SRC, TAR > |
Generic converter to somehow extract values from the "source" type to fill and initialise a tuple of given target type. More... | |
struct | is_Tuple< T > |
trait to detect tuple types More... | |
struct | is_Tuple< std::tuple< TYPES... > > |
struct | RebindTupleTypes< TYPES > |
temporary workaround: match and rebind the type sequence from a tuple More... | |
struct | RebindTupleTypes< std::tuple< TYPES... > > |
struct | StringConv< std::tuple< TYPES... > > |
struct | TupleConstructor< TYPES, _ElmMapper_ > |
Extensible Adapter to construct a distinct tuple from some arbitrary source type. More... | |
struct | TupleElementDisplayer< TY, BASE, TUP, idx > |
Helper to dump tuple contents. More... | |
struct | TupleElementDisplayer< NullType, TUP, TUP, n > |
Typedefs | |
template<class SRC , class TAR , size_t i> | |
using | ExtractArg = typename ElementExtractor< SRC, TAR >::template Access< i > |
template<typename TYPES > | |
using | Tuple = typename BuildTupleType< TYPES >::Type |
Build a std::tuple from types given as type sequence. More... | |
Functions | |
template<typename TYPES , class SRC > | |
Tuple< TYPES > | buildTuple (SRC values) |
convenience shortcut to build a tuple from some suitable source data. More... | |
template<typename... TYPES> | |
std::string | dump (std::tuple< TYPES... > const &tuple) |
convenience function to dump a given tuple's contents. More... | |
template<class FUN , typename... ELMS> | |
void | forEach (std::tuple< ELMS... > &&tuple, FUN fun) |
Helper: perform some arbitrary operation on each element of a tuple. More... | |
template<typename TY > | |
std::string | toString (TY const &val) noexcept |
get some string representation of any object, reliably. More... | |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
using Tuple = typename BuildTupleType<TYPES>::Type |
Build a std::tuple
from types given as type sequence.
Types
to mark a type sequence of types as such. This allows to pass such a sequence as first-class citizen. The standard library often (ab)uses the std::tuple for this purpose, which is an understandable, yet inferior design choice. We should always favour dedicated types over clever re-use of existing types. Definition at line 142 of file tuple-helper.hpp.
struct lib::meta::anonymous_namespace{tuple-helper.hpp}::BuildTupleType< Node< H, TAIL > > |
Class Members | ||
---|---|---|
typedef typename Types< Node < H, TAIL > >::Seq |
Seq | |
typedef typename BuildTupleType< Seq >::Type |
Type |
struct lib::meta::anonymous_namespace{tuple-helper.hpp}::BuildTupleType< NullType > |
Class Members | ||
---|---|---|
typedef typename BuildTupleType< Types <> >::Type |
Type |
struct lib::meta::anonymous_namespace{tuple-helper.hpp}::BuildTupleType< Types< TYPES... > > |
Class Members | ||
---|---|---|
VariadicSeq | ||
typedef typename BuildTupleType< VariadicSeq > ::Type |
Type |
struct lib::meta::anonymous_namespace{tuple-helper.hpp}::BuildTupleType< TySeq< TYPES... > > |
|
inlinenoexcept |
get some string representation of any object, reliably.
A custom string conversion operator is invoked, if applicable, while all lexically convertible types (numbers etc) are treated by boost::lexical_cast. For double or float values, hard wired rounding to a fixed number of digits will be performed, to yield a predictable display of printed unit-test results.
StringConf<TY>
, yet this solution might be brittle. If you want pointers to be indicated (with address), consider using util::showPtr explicitly. Definition at line 200 of file format-obj.hpp.
References util::toString().
Referenced by FormatHelper_test::check2String(), and util::toString().
void lib::meta::forEach | ( | std::tuple< ELMS... > && | tuple, |
FUN | fun | ||
) |
Helper: perform some arbitrary operation on each element of a tuple.
Definition at line 82 of file tuple-helper.hpp.
References lib::meta::forEach().
Referenced by lib::meta::forEach().
Tuple<TYPES> lib::meta::buildTuple | ( | SRC | values | ) |
convenience shortcut to build a tuple from some suitable source data.
For this to work, there needs to be a partial specialisation for (ElementExtractor) to deal with the concrete source type given.
Record<GenNode>
, which allows us to fill an (argument) tuple from a sequence of generic data values, with run-time type compatibility check. Definition at line 253 of file tuple-helper.hpp.
References lib::meta::buildTuple().
Referenced by lib::meta::buildTuple().
|
inline |
convenience function to dump a given tuple's contents.
Using the BuildTupleAccessor, we layer a stack of Instantiations of the TupleElementDisplayer temporarily on top of the given tuple, just to invoke a recursive call chain through these layers and get a string representation of each element in the tuple.
Definition at line 376 of file tuple-helper.hpp.
References lib::meta::dump().
Referenced by lib::meta::dump(), and LateBindInstance_test::verify_cornerCases().