C++ allows templated template parameters like this:
template <template <bool> class T>
struct something1 {};
Bool type can be replaced by a typedef (so there is no requirement for the original type name to appear in the declaration):
typedef bool bool_t;
template <template <bool_t> class T>
struct something2 {};
This works perfectly, but if I try to define a nested structure like this:
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 {};
};
Then the following code fails to compile:
template <bool Value>
struct param {};
typedef something1<param> x1; // ok
typedef something2<param> x2; // ok
typedef enclosing<bool>::something开发者_JAVA技巧3<param> x3; // ok
typedef enclosing<bool>::something4<param> x4; // error
Is this a standard compliant behavior, or am I doing something wrong? I am using MSVS 2008.
EDIT:
I've posted a bug report on Microsoft support forums: Bug ReportThat appears to be a bug in VC++; I verified that the behavior is unchanged in VC++ 2010 SP1. I recommend posting a bug report on MS Connect then posting the link here so we can vote it up.
精彩评论