473,954 Members | 32,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

template typedef support in g++ ?

Given:

template<typena me T,typename Uclass C { };
template<typena me Ttypedef C<T,intC2;

I get:

test.cpp:2: error: template declaration of 'typedef'

Are template typedefs still not supported in g++ 4.1.2?

- Paul
Mar 6 '07 #1
5 8465
Paul J. Lucas wrote:
Given:

template<typena me T,typename Uclass C { };
template<typena me Ttypedef C<T,intC2;

I get:

test.cpp:2: error: template declaration of 'typedef'

Are template typedefs still not supported in g++ 4.1.2?
There are no template typedefs in C++... As to g++ extensions,
you should ask in 'gnu.g++.*' newsgroup hierarchy.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 6 '07 #2
On Mar 6, 3:01 pm, pauljlucas.remo vet...@removeth istoo.mac.com (Paul
J. Lucas) wrote:
Given:

template<typena me T,typename Uclass C { };
template<typena me Ttypedef C<T,intC2;

I get:

test.cpp:2: error: template declaration of 'typedef'

Are template typedefs still not supported in g++ 4.1.2?

- Paul
Maybe what you wanted is this?

template<typena me T,typename Uclass C { };
typedef C<T,intC2;
Adrian

Mar 6 '07 #3
ad************* @gmail.com wrote:
On Mar 6, 3:01 pm, pauljlucas.remo vet...@removeth istoo.mac.com (Paul
J. Lucas) wrote:
>Given:

template<typena me T,typename Uclass C { };
template<typena me Ttypedef C<T,intC2;

I get:

test.cpp:2: error: template declaration of 'typedef'

Are template typedefs still not supported in g++ 4.1.2?

- Paul

Maybe what you wanted is this?

template<typena me T,typename Uclass C { };
typedef C<T,intC2;
'T' seems undefined here. What does your compiler say?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 6 '07 #4
On Mar 6, 5:44 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
adrian.hawry... @gmail.com wrote:
On Mar 6, 3:01 pm, pauljlucas.remo vet...@removeth istoo.mac.com (Paul
J. Lucas) wrote:
Given:
template<typena me T,typename Uclass C { };
template<typena me Ttypedef C<T,intC2;
I get:
test.cpp:2: error: template declaration of 'typedef'
Are template typedefs still not supported in g++ 4.1.2?
- Paul
Maybe what you wanted is this?
template<typena me T,typename Uclass C { };
typedef C<T,intC2;

'T' seems undefined here. What does your compiler say?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oh, I see. I was some how combining Partial Template Specialization
with typedefing a concrete class. Doh!

I wonder what the reasoning is for no templated typedefs. Seems like
a natural extention.
Adrian

Mar 6 '07 #5
Paul J. Lucas wrote:
Given:

template<typena me T,typename Uclass C { };
template<typena me Ttypedef C<T,intC2;

I get:

test.cpp:2: error: template declaration of 'typedef'

Are template typedefs still not supported in g++ 4.1.2?

- Paul
Hi Paul,

At best, if GNU does support this you will probably need to
download an experimental g++ for this. You can check on their
website to see if this is something they do plan to support.

From a C++ standards perspective, I do not think it has been
ratified. I tried to search the C++ standards website for any
information about this issue but I could not find anything
(but does not mean it isn't being addressed).

Here is a suggested workaround while the different groups
address this issue.

template<typena me T,typename Uclass C { };
template<typena me T>
class C2
{
public:
typedef C<T,intType;
};

So now you can do this:

C2<double>::Typ e foo;

A little awkward looking but should hold you out until
typedef templates is addressed (typedef templates is how
it is referred to by Vandevoorde and Josuttis).

HTH
Mar 7 '07 #6

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

Similar topics

11
1890
by: Marcin Kalicinski | last post by:
Hi, How to convert a type inside a template from pointer to type to type itself? struct S { }; template<class It> void f(It begin, It end) { // When called from g(), It::value_type is a pointer to S, but // I want to get S itself, for example to use it in an auto_ptr:
0
1890
by: Gianni Mariani | last post by:
I remember seeing a neat template specialization trick posted here a few months ago that allowed the detection of a type containing a member. After a day searching through google archives I come up zip. Anyhow, after much trial and error I came up with this. This "contains_member" template sets value to 1 if the type D contains a typedef named MEMBER of type TD.
31
3583
by: nikola | last post by:
Hi all, I was working with a simple function template to find the min of two values. But since I would like the two values to be different (type) I dont know what kind of value (type) it will return. I tried to write something like this: template <class Type1, class Type2, class Type3> Type3 findMin(Type1 x, Type2 y){ return (x < y) ? x : y;
5
1787
by: Kenneth Massey | last post by:
I have run into a peculiar problem, in which the following sample code does not compile (gcc 3.3). I have a template class with a member function that should take a const version of the template parameter. However, when I try to use the class with (T=int*), the compiler seems to ignore the const and gives an error if I pass a const int*. Any help would be much appreciated. Kenneth // test.cpp: In function `int main()':
8
1994
by: daniel.w.gelder | last post by:
Hello, I have been trying to write a functor template for a week now and I'm just having tons of trouble because I don't understand an issue that I guess is pretty basic to this task. functor<bool (long, long)> myFunctor; myFunctor = AFunctionOfThatPrototype; To get that much is elementary because the template can just store a (bool)(long,long) as a member variable in functor<T>. Here is the problem:
4
14046
by: pradosh | last post by:
Is it possible to typedef a template class? How? For example: template <class T> class OldClass { }; typedef OldClass<T> NewClass<T>;
6
1594
by: Hendrik Schober | last post by:
Hi, I have a problem with extending some existing code. In a simplified form, the problem looks like this: I have four types, A, B, C, and D. Each A refers to zero, one, or more B's and each B can be child to zero, one, or more A's. I just call that "A is a parent of B", and "B is a child of A". The same goes for B and C and for C and D. So A is only a parent, B and C are both parents and children, and D is only a child.
19
7978
by: aaragon | last post by:
Hi everyone. A very simple question. I would like to know what is better in terms of performance. I want to use a simple function to obtain the minimum of two values. One way could be using a macro: #define min(a,b) ((a<b)?a:b) I thought that another way could be to use a template function: template <class T> T min<T a, T b>
272
14419
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two dimensional arrays from std::vectors ??? I want to use normal Array Syntax.
0
10193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11222
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9922
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7458
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4979
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.