带模板类型的模板化模板参数列表

Jan*_*cek 8 c++ templates metaprogramming template-meta-programming

C++允许模板化的模板参数,如下所示:

template <template <bool> class T>
struct something1 {};
Run Code Online (Sandbox Code Playgroud)

Bool类型可以用typedef替换(因此不需要在声明中出现原始类型名称):

typedef bool bool_t;
template <template <bool_t> class T>
struct something2 {};
Run Code Online (Sandbox Code Playgroud)

这很好用,但如果我尝试定义这样的嵌套结构:

template <typename Type>
struct enclosing
{
   typedef bool bool_t;
   typedef Type type_t; 

   template <template <bool_t> class T>
   struct something3 {};

   template <template <type_t> class T>
   struct something4 {};
};
Run Code Online (Sandbox Code Playgroud)

然后以下代码无法编译:

template <bool Value>
struct param {};

typedef something1<param> x1; // ok
typedef something2<param> x2; // ok
typedef enclosing<bool>::something3<param> x3; // ok
typedef enclosing<bool>::something4<param> x4; // error
Run Code Online (Sandbox Code Playgroud)

这是符合标准的行为,还是我做错了什么?我正在使用MSVS 2008.

编辑:
我在微软支持论坛上发布了一个错误报告: 错误报告

ild*_*arn 4

这似乎是 VC++ 中的一个错误;我验证了 VC++ 2010 SP1 中的行为没有变化。我建议在MS Connect上发布错误报告,然后在此处发布链接,以便我们对其进行投票。