|
Boost Users : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-01-19 13:24:27
Hi,
Sohail Somani wrote:
> If I am trying to make a fusion sequence mpl compatible, do I need to
> specialize mpl::is_sequence as well?
No. mpl::is_sequence just checks whether mpl::begin returns mpl::void_
(in this case it's not an MPL Sequence).
> I had expected that the following should be true:
>
> BOOST_MPL_ASSERT(( fusion::traits::is_sequence<myseq> ));
> BOOST_MPL_ASSERT(( mpl::is_sequence<myseq> ));
It is - once you bring the part of MPL support in that enables you to
use MPL Tag Dispatched Metafunctions on Fusion sequences:
#include <boost/fusion/sequence/intrinsic/mpl.hpp>
>
> But the compilation fails on the second line.
That breakage should be intentional to make sure that mpl::is_sequence
won't start lying, otherwise a Fusion Sequence can be both an MPL
Sequence and not an MPL Sequence in the same program (see attached code).
Note that I fixed that problem very recently, so maybe your version of
mpl::is_sequence is still just lying.
For a recent CVS snapshot, Fusion sequences are always MPL Sequences.
They can be incompletely defined, however (and in this case your
compiler hopefully tells you that begin_impl<fusion_sequence_tag> is an
incomplete type).
Regards,
Tobias
P.S.: The attached code will intentionally fail to compile if your
snapshot of Fusion is up to date.
#include <boost/mpl/is_sequence.hpp>
#include <boost/fusion/sequence/container/vector.hpp>
#include <iostream>
bool is_seq_tu1()
{
return boost::mpl::is_sequence< boost::fusion::vector<int> >::value;
}
bool is_seq_tu2();
int main()
{
if (is_seq_tu1() != is_seq_tu2())
{
std::cout << "ODR violation missed by the linker" << std::endl;
return 1;
}
else
{
std::cout << "Fine." << std::endl;
return 0;
}
}
#include <boost/mpl/is_sequence.hpp>
#include <boost/fusion/sequence/container/vector.hpp>
#include <boost/fusion/sequence/intrinsic/mpl.hpp>
bool is_seq_tu2()
{
return boost::mpl::is_sequence< boost::fusion::vector<int> >::value;
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net