【发布时间】:2010-01-22 16:04:04
【问题描述】:
我想知道 C++0x 是否提供任何内置功能来检查可变参数模板的参数包是否包含特定类型。今天,如果您使用 boost::mpl::vector 作为可变参数模板的替代品,则可以使用 boost:::mpl::contains 来完成此操作。但是,它具有严重的编译时间开销。我想,C++0x 对 std::is_same 有编译器级别的支持。所以我在想编译器是否也支持in这样的概括。
template <typename... Args, typename What>
struct is_present
{
enum { value = (What in Args...)? 1 : 0 };
};
【问题讨论】:
标签: c++ c++11 templates metaprogramming variadic