【发布时间】:2015-05-15 04:03:33
【问题描述】:
考虑以下代码:
template< template< typename ... > class ... Ts >
struct unite
{
template< typename ... T >
struct type
: Ts< T ... > ...
{ };
};
// This does not work as ::type does not name a type, but a template:
// template< template< typename ... > class ... Ts >
// using unite_t = typename unite< Ts ... >::type;
template< typename > struct debug_none {};
template< typename > struct debug_cout {};
template< typename ... > struct raise_demangled {};
template< typename ... > struct raise_specialized {};
template< typename, typename = int > struct match_default {};
template< template< typename ... > class Control >
void f()
{}
int main()
{
f< unite< debug_none, raise_demangled, match_default >::type >();
// Is there any way to create something like unite_t which works like this:
// f< unite_t< debug_none, raise_demangled, match_default > >();
}
问题:有什么方法可以创建某种类似于类型别名的“模板别名”?(参见上例中的unite_t)
【问题讨论】:
-
所以,问题:我记得我在写的时候曾经问过这个确切的问题。我应该关闭我的stackoverflow.com/questions/17356487/… 作为这个的副本吗?或相反亦然? :)
-
@Yakk 尽管您的问题非常相似并且在同一区域,但我认为这并不是真正的重复,因为您试图在不同的地方摆脱
template关键字。如果一个会的解决方案存在,它可能也能解决另一个问题 - 但似乎没有解决方案。
标签: c++ c++11 c++14 type-alias