Representing of empty sequence

Hi All,
I am trying to understand the implementation of mpl::vector. I have
simplified greatly to help understand it. I am now trying to figure
out how to represent an empty sequence. Here is what I have got:
template <class T0>
struct vector1
{
typedef vector1 type;
};
template

AMDG Missing Rainbow wrote:
I am trying to understand the implementation of mpl::vector. I have simplified greatly to help understand it. I am now trying to figure out how to represent an empty sequence. Here is what I have got:
template <class T0> struct vector1 { typedef vector1 type; };
<snip>
template<T0> struct vector : vector1<T0> {};
<snip>
How to declare and make use of an empty sequence?
The easiest way is to use a simple struct struct vector0 { typedef vector0 type; }; template<> struct vector<> : vector0 {}; MPL uses a little trick to make vector0 consistent with vector1, etc. template<class Dummy = na> struct vector0 { typedef vector0 type; }; template<> struct vector<> : vector0<> {}; Note the the Dummy parameter is never expected to be used. It just allows the use of <>. In Christ, Steven Watanabe
participants (2)
-
Missing Rainbow
-
Steven Watanabe