Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > template template parameters with a default - build error that oncedid not occur (new gcc?)

Reply
Thread Tools

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

 
 
er
Guest
Posts: n/a
 
      08-24-2008
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!
 
Reply With Quote
 
 
 
 
er
Guest
Posts: n/a
 
      08-24-2008
On Aug 24, 4:41*pm, er <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      08-25-2008
er wrote:
> 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>

--
Ian Collins.
 
Reply With Quote
 
er
Guest
Posts: n/a
 
      08-25-2008
On Aug 25, 1:22*am, Ian Collins <(E-Mail Removed)> wrote:
> er wrote:
> > 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>
>
> --
> Ian Collins.


OK, thanks!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
skipping template parameters inside template parameters kito C++ 2 09-26-2010 12:04 AM
Element is not a known element. This can occur if there is a compilation error in the Web site MK ASP .Net 5 06-27-2008 07:20 PM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
Show 4 Records that occur more often...and how often they occur. Miguel Dias Moura ASP .Net 4 05-06-2004 03:40 PM



Advertisments