// first, some types that I plan to use
template< typename tag, uint32_t _data >
struct DType
{
using typeTag = tag;
uint32_t payload = _data;
};
template< typename tag >
struct AType
{
using typeTag = tag;
int32_t process () { return 0; };
};
template< typename tag >
struct VType
{
using typeTag = tag;
bool verify() { return true; };
};
// define a bunch of type tags
using inputA = mp_int< 0 >;
using inputB = mp_int< 1 >;
using ProcA = mp_int< 2 >;
using ProcB = mp_int< 3 >;
using VrfyA = mp_int< 4 >;
// then all the possible types stores in a list
using TypePool = mp_list< DType, DType, DType,
AType< ProcA >, AType< ProcB >,
VType< VrfyA > >;
// provide a filter list
using filter = mp_list< inputB, ProcA, VrfyA >;
// so far so good, what I want is to create a bunch of mp_lists according to
// the filter from the TypePool; ideally I want something like following:
// just to show what's the final result looks like
using list1 = mp_list< DType< inputB, 1 >, AType< ProcA >, VType< VrfyA > >;
using list2 = mp_list< DType< inputB, 2 >, AType< ProcA >, VType< VrfyA > >;
По сути, я выбираю тип из TypePool в соответствии с тегами, перечисленными в
Я практикую метапрограммирование шаблонов C++ (TMP), используя библиотеку boost::mp11. Я хочу добиться следующего: [code]// first, some types that I plan to use template< typename tag, uint32_t _data > struct DType { using typeTag = tag; uint32_t payload = _data; };
template< typename tag > struct AType { using typeTag = tag; int32_t process () { return 0; }; };
template< typename tag > struct VType { using typeTag = tag; bool verify() { return true; }; };
// define a bunch of type tags using inputA = mp_int< 0 >; using inputB = mp_int< 1 >; using ProcA = mp_int< 2 >; using ProcB = mp_int< 3 >; using VrfyA = mp_int< 4 >;
// then all the possible types stores in a list using TypePool = mp_list< DType, DType, DType, AType< ProcA >, AType< ProcB >, VType< VrfyA > >;
// provide a filter list using filter = mp_list< inputB, ProcA, VrfyA >;
// so far so good, what I want is to create a bunch of mp_lists according to // the filter from the TypePool; ideally I want something like following:
// just to show what's the final result looks like using list1 = mp_list< DType< inputB, 1 >, AType< ProcA >, VType< VrfyA > >; using list2 = mp_list< DType< inputB, 2 >, AType< ProcA >, VType< VrfyA > >; [/code] По сути, я выбираю тип из TypePool в соответствии с тегами, перечисленными в [code]filter. А затем создайте новые списки в соответствии с порядком, заданным в фильтре[/code]. Все списки имеют переменную длину. Есть предложения, как это сделать?