Fusion question- equality of tuples vs mpl sequences

/// Testing remove { typedef vector<Y, char, long, X, bool, double> mpl_vec; BOOST_TEST((fusion::remove(mpl_vec(), identity<X>()) == tuple<Y, char, long, bool, double>())); BOOST_TEST((fusion::remove(mpl_vec(), identity<Y>()) == tuple<char, long, X, bool, double>())); BOOST_TEST((fusion::remove(mpl_vec(), identity<long>()) == tuple<Y, char, X, bool, double>())); } My question is how does the above WORK? What caught my attention is the char,long,bool, and double have undefined values in them. Is it that when performing a ==, if one is comparing a mpl sequence the equality is based solely on TYPE? (is that what is going on?) Thanks, Brian :)

--- Brian Braatz <brianb@rmtg.com> wrote:
/// Testing remove
{ typedef vector<Y, char, long, X, bool, double> mpl_vec; BOOST_TEST((fusion::remove(mpl_vec(), identity<X>()) == tuple<Y, char, long, bool, double>())); BOOST_TEST((fusion::remove(mpl_vec(), identity<Y>()) == tuple<char, long, X, bool, double>())); BOOST_TEST((fusion::remove(mpl_vec(), identity<long>()) == tuple<Y, char, X, bool, double>())); }
My question is how does the above WORK? What caught my attention is the char,long,bool, and double have undefined values in them.
The mpl::vector doesn't have any values in it, never mind undefined ones. (See later)
Is it that when performing a ==, if one is comparing a mpl sequence the equality is based solely on TYPE? (is that what is going on?)
No thats not correct. Fusion can iterate over an MPL sequence, even though that sequence does not have values in it. To do this when a fusion iterator over an MPL is dereferenced, it returns a default constructed value of the current element type. So for example mpl::vector<int,char> can be thought of as a sequence containing elements int() and char(). So operator == checks the sequences are the same size, then creates fusion iterators to iterate over the sequence, and compares all the (default constructed) values. Hope that helps. Cheers Dan ___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
participants (2)
-
Brian Braatz
-
dan marsden