template template parameters with a default - build error that oncedid not occur (new gcc?)

E

er

Hi all,

I have some build errors related to template templates that once
compiled fine, but not anymore. i'm guessing this might be due to an
upgrade in gcc (i upgraded from ubuntu 7.10 to 8.04).

suppose i have a template class like this:

template<typename ValueType,template<typename> class F>
struct A{
typedef F<ValueType> f_type;
};

and in a source file I have:

typedef A<ValueType,std::vector> a_type;

This used to work fine, not anymore:

expected a template of type ‘template<class> class F’, got
‘template<class _Tp, class _Alloc> class std::vector’

I understand this error message, it's just that _Alloc usually has a
default, which previously allowed the definition of A as above, not
anymore! I have to refactor my code, any suggestion?

Thanks!
 
E

er

Hi all,

I have some build errors related to template templates that once
compiled fine, but not anymore. i'm guessing this might be due to an
upgrade in gcc (i upgraded from ubuntu 7.10 to 8.04).

suppose i have a template class like this:

template<typename ValueType,template<typename> class F>
struct A{
  typedef F<ValueType> f_type;

};

and in a source file I have:

typedef A<ValueType,std::vector> a_type;

This used to work fine, not anymore:

expected a template of type ‘template<class> class F’, got
‘template<class _Tp, class _Alloc> class std::vector’

I  understand this error message, it's just that _Alloc usually has a
default, which previously allowed the definition of A as above, not
anymore! I have to refactor my code, any suggestion?

Thanks!

ps: i believe I'm using gcc 4.2.3
 
I

Ian Collins

er said:
Hi all,

I have some build errors related to template templates that once
compiled fine, but not anymore. i'm guessing this might be due to an
upgrade in gcc (i upgraded from ubuntu 7.10 to 8.04).

suppose i have a template class like this:

template<typename ValueType,template<typename> class F>
struct A{
typedef F<ValueType> f_type;
};

and in a source file I have:

typedef A<ValueType,std::vector> a_type;

This used to work fine, not anymore:

expected a template of type ‘template<class> class F’, got
‘template<class _Tp, class _Alloc> class std::vector’

I understand this error message, it's just that _Alloc usually has a
default, which previously allowed the definition of A as above, not
anymore! I have to refactor my code, any suggestion?
Bite the bullet and change it! The latest C++ 0x draft standard says
explicitly that default arguments are not considered.

You'll want something like:

template<typename V,template<typename E,
typename A = std::allocator<E> > class F>
 
E

er

Bite the bullet and change it!  The latest C++ 0x draft standard says
explicitly that default arguments are not considered.

You'll want something like:

template<typename V,template<typename E,
                             typename A = std::allocator<E> > class F>

OK, thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top