Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Variadic templates and CRTP

7 views
Skip to first unread message

Alban Linard

unread,
Oct 19, 2009, 4:31:21 AM10/19/09
to
Hi,

either i do not understand some parts of variadic templates, or g++
has an erronous handling of types canonization when using variadic
templates and CRTP. Exemple code below.

/* g++-mp-4.5 (GCC) 4.5.0 20091001 (experimental)
* g++-mp-4.5 -std=c++0x bug.cc
* In function 'int main()':
* 25:41: error: invalid initialization of reference of type 'base<a,
derived<a> >&' from expression of type 'derived<a>'
* (hint: internal compiler error on some other uses, canonical types
differ for identical types, for 'base<a, derived<a> >')
*/

struct a {};

template < typename T, typename ENCLOSING >
struct base;

template < typename ENCLOSING >
struct base< a, ENCLOSING >
{};

template < typename... T >
struct derived
: public base< T, derived< T... > >...
{};

int main()
{
derived< a > instance;
base< a, derived< a > >& a_instance = instance;
}

What have i done wrong or is it a bug ?
Thanks,
Alban Linard

0 new messages