Hi,
I need to run boost::mpl::for_each<> function with template condition, like:
boost::mpl::for_each< vector_of_types,
boost::mpl::make_identityboost::mpl::_1 > (Functor< condition >());
I'm trying to implement lazy binding in enable_if.
Visual studio fails with error "'Xboost::mpl::_>::operator ()' :
ambiguous call to overloaded function"
minimal test code which fail on boost 1.57
#include
#include
#include
#include
#include
#include <iostream>
#include
template <int> struct dummy { dummy(int) {} }; // from doc
struct Foo {};
struct Bar {};
template <typename T>
struct IsFoo
{
typedef typename std::is_same::type type;
};
#define generate_type(_fn) \
typename boost::mpl::applyboost::mpl::_ >::type, \
boost::mpl::bind::type, U> \
> >::type
#define enable_type generate_type(boost::enable_if)
#define disable_type generate_type(boost::disable_if)
template <typename _Pred>
struct X
{
template <typename U>
enable_type operator()(boost::mpl::identity<U>, dummy<0> = 0) const
{
std::cout << "enable: " << typeid(U).name() << std::endl;
}
template <typename U>
disable_type operator()(boost::mpl::identity<U>, dummy<1> = 0) const
{
std::cout << "disable: " << typeid(U).name() << std::endl;
}
};
int main()
{
Xboost::mpl::_ > x;
x(boost::mpl::identity<Foo>());
x(boost::mpl::identity<Bar>());
return 0;
}