测试boost :: mpl :: or_的计算结果是true还是false

时间:2014-06-04 22:37:51

标签: c++ c++11 boost

我如何测试or_评估为真还是假?

说我有

typedef boost::mpl::or_<
    boost::is_same<ExPolicy,sequential_execution_policy>,
    boost::is_same<InIter, std::input_iterator_tag>,
    boost::is_same<OutIter, std::output_iterator_tag>
> is_seq;

我该如何测试结果?目前我试着做

auto h = is_seq();
if(h == boost::mpl::true_::value)

但是当我知道我的程序中至少一个的情况为真时,所有内容的评估都为false。我该怎么做才能知道价值?

1 个答案:

答案 0 :(得分:3)

使用is_seq::value。例如:

template<typename T>
using type = boost::mpl::or_<
                std::is_same<T, char>,
                std::is_same<T, int>
             >;
int main() 
{
    std::cout << type<int>::value << std::endl;
    std::cout << type<long>::value << std::endl;
}

输出:

1
0

Live demo