Is the number of types in a C++ template variant limited? -
I am trying to understand how variants apply, and read:
< / P>
And I have the impression that I can not write a type which takes x type; But the template author raises some N, and I can only do less than one-one type in one type.
Is that correct?
Thank you!
In C ++ 03, there are no variation templates; this means yes; You just have to go up some n, and have to stay with it.
In C ++ 0x, there will be different templates, so that you can use a definition for all X.
If you want to change the number, you can use it and it can work for you:
#define MAXIMUM_TYPELIST_SIZE 20 // or something Empty {}; Template & lt; BOOST_PP_ENUM_BINARY_PARAMS (MAXIMUM_TYPELIST_SIZE, typename T, = empty) & gt; Structure typewrite; Template & lt; BOOST_PP_ENUM_PARAMS (MAXIMUM_TYPELIST_SIZE, typename T) & gt; Structure typewrite {type DEFED T1 head; Typitic tip type & lt; BOOST_PP_ENUM_PARAMS (BOOST_PP_DEC (MAXIMUM_TYPELIST_SIZE), t) & gt; Tail; Enum {length = tail :: length + 1}; };
If MAXIMUM_TYPELIST_SIZE
was 5, then those macros would be expanded for the article.
(Of course, if you are using Boost just use them.)
Comments
Post a Comment