Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

templated template parameter list with template types

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>::something3<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 Report

like image 358
Jan Holecek Avatar asked Mar 31 '11 09:03

Jan Holecek


1 Answers

That 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.

like image 156
ildjarn Avatar answered Oct 13 '22 04:10

ildjarn