c++ - 测试 boost::mpl::or_ 的计算结果是真还是假

标签 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)

但是当我知道我的程序中至少一个案例为真时,一切都评估为假。我该怎么做才能知道该值?

最佳答案

使用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

关于c++ - 测试 boost::mpl::or_ 的计算结果是真还是假,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24048757/

相关文章:

C++ 预期主表达式编译错误

qt - 使用不同的文件系统库实现Qt文件对话框( boost )

c++ - 在 IShellFolder::EnumObjects() 中使用 IShellBrowser::BrowseObject()

c++ - 如何使用特征库进行 lu 分解 C++

c++ - push_back vector<char> 中的所有内容,将它们合并为 vector<string> 的第一个元素

c++ - Qt C++ - 对 ... 内联 QImage 自定义函数的 undefined reference

c++ - vector 增长时如何强制执行 move 语义?

不使用静态存储的基于 C++ 类型的缓存

c++ - C++11 中的空宏参数合法吗?

c++ - 使用 boost karma 重用已解析的变量