473,326 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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<typenameclass F>
struct A{
typedef F<ValueTypef_type;
};

and in a source file I have:

typedef A<ValueType,std::vectora_type;

This used to work fine, not anymore:

expected a template of type ‘template<classclass F’, got
‘template<class _Tp, class _Allocclass 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!
Aug 24 '08 #1
3 1274
er
On Aug 24, 4:41*pm, er <erwann.rog...@gmail.comwrote:
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<typenameclass F>
struct A{
* typedef F<ValueTypef_type;

};

and in a source file I have:

typedef A<ValueType,std::vectora_type;

This used to work fine, not anymore:

expected a template of type ‘template<classclass F’, got
‘template<class _Tp, class _Allocclass 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
Aug 24 '08 #2
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<typenameclass F>
struct A{
typedef F<ValueTypef_type;
};

and in a source file I have:

typedef A<ValueType,std::vectora_type;

This used to work fine, not anymore:

expected a template of type ‘template<classclass F’, got
‘template<class _Tp, class _Allocclass 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.
Aug 25 '08 #3
er
On Aug 25, 1:22*am, Ian Collins <ian-n...@hotmail.comwrote:
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<typenameclass F>
struct A{
* typedef F<ValueTypef_type;
};
and in a source file I have:
typedef A<ValueType,std::vectora_type;
This used to work fine, not anymore:
expected a template of type ‘template<classclass F’, got
‘template<class _Tp, class _Allocclass 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!
Aug 25 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and...
5
by: dilip ranganathan | last post by:
Hi I have taken the liberty to cross-post this. It appeared on c.l.c++.m but the ICE is regarding VS.NET 7.1 C++ compiler. post follows: ==============================================...
2
by: Ron | last post by:
Hello, I am trying to create a page that pulls class rosters from an SQLServer database. The roster table definition is: emp_id(pk, fk), sec_id(pk, fk), reg_date and reg_status. Status can be...
2
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template...
8
by: Paul Roberts | last post by:
Hi, I'm hoping somebody here can help me with a simple problem of template syntax. Here's an example: template<typename T, int iclass A { static int a;
12
by: aaragon | last post by:
Hello all. I have a simple question that seems trivial but I can't make it to work. I have a class that takes as a template argument, another class. The idea is as follows: #include...
5
by: krishnaroskin | last post by:
Hey all, I've been running into a problem with default values to template'd functions. I've boiled down my problem to this simple example code: #include<iostream> using namespace std; //...
2
by: ndbecker2 | last post by:
On upgrading from gcc-4.1.2 to gcc-4.3, this (stripped down) code is now rejected: #include <vector> #include <iostream> template<typename T, template <typename Aclass CONT=std::vector>...
8
by: William Xu | last post by:
Compiling: template <class T = int> T foo(const T& t) {} int main(int argc, char *argv) {} gcc complains:
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.