How to use std::tuple types with boost::mpl algorithms?

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 
#include 
#include 

namespace mpl=boost::mpl;

typedef mpl::vector types;
static_assert(mpl::contains::value, "vector contains bool");

typedef std::tuple types2;
// the following does not compile:
// error: no class template named ‘apply’ in ‘struct boost::mpl::contains_impl’
static_assert(mpl::contains::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 for boost::tuple)?
  • If not, would it be possible to carry over the fusion implementation for boost::tuple to std::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).

6
задан Matteo Italia 24 February 2011 в 01:39
поделиться