【发布时间】:2017-04-13 11:56:25
【问题描述】:
是否可以重新映射我们在参数包扩展期间获得的列表中的类型?
假设我们有下一个类型,我们想用作模板参数:
struct A {
typedef char type;
};
struct B {
typedef float type;
};
struct C {
typedef void* type;
};
这是类模板:
template <typename... Args>
struct Foo {
// after expansion should be
// void bar(Arg0::type, Arg1::type, Arg2::type, ...)
void bar(/* expand Args here */) {}
};
我们应该如何扩展Args 得到Foo::bar(Arg0::type, Arg1::type, Arg2::type, ...)?
Foo<A, B, C> f;
// now there should be method void f::bar(A::type, B::type, C::type)
f.bar('a', 1.f, nullptr);
有可能吗?
【问题讨论】:
标签: c++ c++11 templates variadic-templates