This is a general tuple class that can pack together elements of different types. Furthermore, individual elements can be marked as constant so that they won't occupy memory in the pack object. More...
#include <array.hpp>
Public Member Functions | |
| pack () | |
| All non-static elements are initialized to their default value. | |
| pack (const type0 &a0) | |
| All non-static elements are initialized to their default value except i0 is initialized to a0. | |
| pack (const type0 &a0,..., const typeN &aN) | |
| All non-static elements are initialized to the corresponding supplied value. The rest are ignored. | |
| template<typename other_type0_ , ... , typename other_typeN_ > | |
| pack (const pack< other_type0_,..., other_typeN_ > &other) | |
| All non-static elements are initialized to the corresponding supplied value. The rest are ignored. | |
| pack & | operator= (const pack &other) |
| All non-static elements are copied from other. | |
| template<typename other_type0_ , ... , typename other_typeN_ > | |
| pack & | operator= (const pack< other_type0_,..., other_typeN_ > &other) |
| All non-static elements are copied from other. | |
| void | set (const type0 &a0,..., const typeN &aN) |
| All non-static elements are set to the corresponding supplied value. | |
Public Attributes | |
| typedef | typeX |
| type of element X where (0<= X <= N) | |
| typeX | iX |
| definition of element X if not marked as constant where (0<= X <= N) | |
Static Public Attributes | |
| static const int | n = N+1 |
| The number of element is the pack (i.e. the number of template parameters). | |
| static const bool | is_constX = ... |
| true if element X is a static const where (0<= X <= N) | |
| static const bool | is_all_const = ... |
| true if all elements are static const and the pack is empty | |
| static const typeX | iX = valueX_ |
| definition of element X if marked as constant where (0<= X <= N) | |
This is a general tuple class that can pack together elements of different types. Furthermore, individual elements can be marked as constant so that they won't occupy memory in the pack object.
A pack object can have from 0 upto LITE_ARRAY_MAX_PACKS elements (see Changing the Limists and Regenerating The Header File. on how to change the limits). The elements are declared public and names i0, i1 ... For any X in [0,N], If the type of element iX which we denote by typeX_ is lite::constant<typeX__,valueX_> then the element iX will be a static const of type typeX__ and with the constant value of valueX_. Otherwise it will be a normal class member of type typeX_. The name of the element X variable is iX . The following is te pseudo class definition of the pack class.
template<typename type0_ ... , typename typeN_> class pack { public: static const int n = N+1; typedef ??? type0; // type of element 0 . . . typedef ??? typeN; // type of element N static const bool is_const0 = ???; // true if element 0 is a static constant . . . static const bool is_constN = ???; // true if element 0 is a static constant static const bool is_all_const = ???; // true if all elements are static constant and the pack is empty // if element 0 is constant then: static const type0 i0 = value0_; // otherwise: type0 i0; . . . // if element N is constant then: static const typeN iN = valueN_; // otherwise: typeN iN; pack(); pack(const type0& a0); pack(const type0& a0, ... , const typeN& aN); template<typename other_type0_, ... , typename other_typeN_> pack(const pack<other_type0_, ... , other_typeN_>& other); pack& operator= (const pack& other); template<typename other_type0_, ... , typename other_typeN_> pack& operator= (const pack<other_type0_, ... , other_typeN_>& other); void set(const type0& a0, ... , const typeN& aN); };
pack<int, constant<int, 5>, std::string> p(1, 0, "hello");
std::cout << p << std::endl;
The output would be:
1 5 hello
1.6.0