Thread View: comp.std.c++
2 messages
2 total messages
Started by Tomohira Tabata
Thu, 14 Dec 1995 04:52
Re: alias name of parameterized class
Author: Tomohira Tabata
Date: Thu, 14 Dec 1995 04:52
Date: Thu, 14 Dec 1995 04:52
35 lines
1914 bytes
1914 bytes
>>>>> On 14 Dec 1995 02:55:53 +0900, clamage@Eng.Sun.Com (Steve Clamage) said:
>> In article WAA24242@k4.k2.t.u-tokyo.ac.jp, TABATA Tomohira <loba@k2.t.u-tokyo.ac.jp> writes:
>> Is the following use of typedef allowed to make alias names of
>> a parameterized class?
>>
>> template <class T> ParameterizedClass { /* ... */ };
>> typedef ParameterizedClass PC;
>> No, because "ParameterizedClass" is not the name of a type. (A template
>> is not a type.)
>> You can write, for example.
>> typedef ParameterizedClass<int> PCint;
>> because ParameterizedClass<int> is the name of a type.
I wonder we have no method of giving a template a different name.
Typedef provides a new concept to a type, for example.
typedef int size_t;
In the same manner I'd like to give a alias to a template. I know it
is possible using #define.
#define MyContainer Vector
We need a method independent of the preprocessor for the purpose.
------
Tomohira Tabata loba@k2.t.u-tokyo.ac.jp
Department of Mathematical Engineering and Information Physics,
Faculty of Engineering, University of Tokyo, Japan
TEL: +81-3-3812-2111 ext. 6902 FAX: +81-3-5800-6969
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: alias name of parameterized class
Author: Tero Pulkkinen
Date: Thu, 14 Dec 1995 20:17
Date: Thu, 14 Dec 1995 20:17
30 lines
1639 bytes
1639 bytes
In article <199512140426.NAA01763@k9.k2.t.u-tokyo.ac.jp> loba@k2.t.u-tokyo.ac.jp (Tomohira Tabata) writes: I wonder we have no method of giving a template a different name. Typedef provides a new concept to a type, for example. typedef int size_t; In the same manner I'd like to give a alias to a template. I know it is possible using #define. #define MyContainer Vector We need a method independent of the preprocessor for the purpose. Doesnt this work? template <class T> typedef Vector<T> MyContainer; Well, it didnt work with g++2.7.0. Though i dont know why wouldn't it work. Reading the september working paper i didnt found anything, what would forbid using it, and typedef is a simple-declaration and should be allowed in template declaration, wouldnt it? [temp.2], [dcl.dcl.1], [dcl.spec.1] So i guess its not yet implemented in g++ or i cant read the draft... -- -- Tero Pulkkinen -- terop@kotka.cs.tut.fi -- --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads