This class can be used to define and extract a subset of element of a pack as another pack. More...
#include <array.hpp>
Public Types | |
typedef pack_type_ | input_pack_type |
The original pack type. | |
typedef pack<...> | type |
The subset pack type. | |
Static Public Member Functions | |
static void | set (type &res, input_pack_type::type0 a0,..., input_pack_type::typeN aN) |
Set the elements of res using only the corresponding elements from a0 to aN. | |
static void | set (type &res, const input_pack_type &org) |
Set the elements of res using only the corresponding elements from org. |
This class can be used to define and extract a subset of element of a pack as another pack.
The following is te pseudo class definition of the sub_pack class.
template<typename type0_, ..., typename typeN_, bool keep0_, ..., bool keepN_> class sub_pack<pack<type0_, ... , typeN_>, keep0_, ..., keepN_> { public: typedef pack<type0_, ... , typeN_> input_pack_type; typedef pack<???> type; // for each X in in [0, N], typeX_ is included only if keepX_ is true. static void set(type& res, input_pack_type::type0 a0, ..., input_pack_type::typeN aN); static void set(type& res, const input_pack_type& org); };
typedef pack<int, constant<int, 5>, std::string> Pack; typedef sub_pack<Pack, true, true, false> SubPack; Pack p(1, 0, "hello"); SubPack::type sub_p; SubPack::set(sub_p, p); std::cout << p << std::endl; std::cout << sub_p << std::endl;
The output would be:
1 5 hello 1 5