【发布时间】:2011-05-17 15:52:24
【问题描述】:
请原谅这里对 C++ 类型推导的任何无知,但我希望能够携带参数包的定义,以便稍后我可以测试内部类型。这可能吗?比如:
template <typename... Args> struct Entity {
struct Inner {
typedef Args... entity_args_t;
};
struct SomeOtherInner {
typedef Args... entity_args_t;
};
};
struct ThingA : Entity<int, string> {
};
struct ThingB : Entity<string, string> {
};
//Want to accept variations of Entity<...>::Inner,
//not Entity<...>::SomeOtherInner
template<typename I>
struct is_Entity_Inner {
static const bool value
= is_same<
typename Entity<typename I::entity_args_t...>::Inner
, I
>::value
;
};
喂?不是吗?
【问题讨论】:
标签: c++ templates parameters c++11 variadic-templates