C++ Boost-MPL和uu类型

C++ Boost-MPL和uu类型,c++,metaprogramming,boost-mpl,C++,Metaprogramming,Boost Mpl,我试图在代码中使用and,但它的返回类型有问题。我试图将它与其他接受并返回true\u类型或false\u类型的元编程结构一起使用,并且我还将SFINAE重载与这些类型一起使用。boost::mpl::and_u和boost::mpl::or_u返回的类型与mpl的其余部分不同。至少在我看来是这样的 mpl_::failed************ boost::is_same<mpl_::bool_<true>, boost::integral_constant<boo

我试图在代码中使用and,但它的返回类型有问题。我试图将它与其他接受并返回true\u类型或false\u类型的元编程结构一起使用,并且我还将SFINAE重载与这些类型一起使用。boost::mpl::and_u和boost::mpl::or_u返回的类型与mpl的其余部分不同。至少在我看来是这样的

mpl_::failed************ boost::is_same<mpl_::bool_<true>, boost::integral_constant<bool, true> >::************)
mpl::失败************boost::是否相同::**************)
那么,我如何编写下面的代码,以便它通过断言

template <typename T, typename U>
void foo(const T& test, const U& test2)
{
    typedef typename boost::mpl::and_<typename utilities::is_vector<T>, typename utilities::is_vector<U> >::type asdf;
    BOOST_MPL_ASSERT(( boost::is_same<asdf, boost::true_type::value> ));
}

void fooer()
{
    std::vector<int> test1;
    std::vector<int> test2;
    foo(test1, test2);
}
模板
无效foo(常数T和测试、常数U和测试2)
{
typedef typename boost::mpl::和::type asdf;
BOOST_MPL_断言((BOOST::is_same));
}
void foore()
{
std::向量test1;
std::向量test2;
foo(test1、test2);
}

BOOST\u MPL\u ASSERT需要一个元函数谓词,即返回类型可以解释为“true”或“false”的元函数,即返回类型为BOOST::MPL::true\u或BOOST::MPL::false

根据定义,类型“asdf”满足此需求,因此无需显式地对照任何元编程抽象检查它是否为“true”,编写
BOOST\u MPL\u ASSERT((asdf))
正是您想要的


当然,如果您愿意,您也可以显式地将其与“true”进行比较,但随后您必须将其与boost::mpl::true\u进行比较,它与boost::true\u类型并不完全相同,因此会产生混淆

使用C++11可能更容易:

static_assert(asdf::value, "T and U aren't both vectors!");

static_断言(std::is_same::value,“T和U不都是向量!”);
static_assert(std::is_same<asdf, boost::true_>::value, "T and U aren't both vectors!");