The boost::mpl
algorithms seem not to be able to work on std::tuple
types out of the box, e.g., the following does not compile (boost-1.46.0, g++ snapshot 2011-02-19):
#include <tuple>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/contains.hpp>
namespace mpl=boost::mpl;
typedef mpl::vector<int,float,bool> types;
static_assert(mpl::contains<types, float>::value, "vector contains bool");
typedef std::tuple<int,float,bool> types2;
// the following does not compile:
// error: no class template named ‘apply’ in ‘struct boost::mpl::contains_impl<boost::mpl::non_sequence_tag>’
static_assert(mpl::contains<types2, float>::value, "tuple contains bool");
What is the easiest way to make the boost::mpl
algorithms work on std::tuple
?
- Does evtl.
boost::fusion
provide this functionality (as it does so forboost::tuple
)? - If not, would it be possible to carry over the fusion implementation for
boost::tuple
tostd::tuple
easily? - If not either, do I really have to implement all the intrinsic metafunctions listed in the MPL documentation or which ones would be sufficient? (The docs only says "many of intrinsic metafunctions offer a default implementation that will work in majority of cases", but it is not clear which ones exactly. And some tests with just providing begin and end did not lead me anywhere).
Converting from std::tuple to boost types and back seems to be the easiest way
*tested with:
boost_1_46_0 and g++-4.5 on MacOSx
boost_1_45_0 and g++-4.5 on Ubuntu 10.10