Topic: typedef X;


Author: andrewfg@aifh.ed.ac.uk
Date: 1995/09/26
Raw View

In article <MATT.95Sep20135311@physics2.Berkeley.EDU> craig@mccabe.com (Craig P. Forbes) writes:
> My understanding is that the typename keyword may only be used in templates
> to identify subtypes of the template parameters, which otherwise can not be
> identified as a type.
>

I like keywords, but why not just use 'class' here?  It is the existing
idiom.  Even for enums and builtins, it serves the purpose -- that of
resolving the ambiguity -- and D&E says that 'class' is the C++ for 'type'.

A.

---
[ 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. ]





Author: andrewfg@aifh.ed.ac.uk
Date: 1995/09/26
Raw View
In article <MATT.95Sep20135311@physics2.Berkeley.EDU> craig@mccabe.com (Craig P. Forbes) writes:
> My understanding is that the typename keyword may only be used in templates
> to identify subtypes of the template parameters, which otherwise can not be
> identified as a type.
>

I like keywords, but why not just use 'class' here?  It is the existing
idiom.  Even for enums and builtins, it serves the purpose -- that of
resolving the ambiguity -- and D&E says that 'class' is the C++ for 'type'.

A.
---
[ 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. ]





Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1995/09/27
Raw View
In article 9509261230@emerald.aifh.ed.ac.uk, andrewfg@aifh.ed.ac.uk writes:
>In article <MATT.95Sep20135311@physics2.Berkeley.EDU> craig@mccabe.com (Craig P. Forbes) writes:
>> My understanding is that the typename keyword may only be used in templates
>> to identify subtypes of the template parameters, which otherwise can not be
>> identified as a type.
>>
>
>I like keywords, but why not just use 'class' here?  It is the existing
>idiom.  Even for enums and builtins, it serves the purpose -- that of
>resolving the ambiguity -- and D&E says that 'class' is the C++ for 'type'.

It would create too many ambiguities. For example:

 template<class base> class der : public base {
  int f();
 };
 template<class base> int der<base>::f()
 {
  class T* tp; // supposing we took your suggestion
  ...
 }

Is "class T" a forward declaration of a new type, or does it refer
to a type T inherited from "base"?

The word "class" has more than one meaning. One of its meanings is
"type" when used in template angle brackets, but that isn't its only meaning.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ 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. ]





Author: Haim Kreitman <haim_kreitman@mail.stil.scitex.com>
Date: 1995/09/17
Raw View
STL uses in many places typedef with only one identificator.
I couldn't find such kind of sintax in draft.

typedef type1 type2;   // like in C
typedef type1;         // what does it mean ???


-- Haim Kreitman,
-- haim_kreitman@mail.stil.scitex.com,
-- Scitex Corp.  Israel.


[Moderator's note: the STL documentation has some "code" that isn't
code.  This sort of line isn't supposed to be legal C++, it's just
supposed to indicate that type1 is a typedef for something.  mha]

---
[ 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. ]





Author: Etay_Bogner@mail.stil.scitex.com (Etay Bogner)
Date: 1995/09/17
Raw View
In article <MATT.95Sep16194450@Austern>, Haim Kreitman
<haim_kreitman@mail.stil.scitex.com> wrote:

>> typedef type1;         // what does it mean ???

>> [Moderator's note: the STL documentation has some "code" that isn't
>> code.  This sort of line isn't supposed to be legal C++, it's just
>> supposed to indicate that type1 is a typedef for something.  mha]

Haim and me once thought that this is a forward declaration for a type.
While reading the draft, I've noticed that there is a new keyword,
"typename", that is used for that purpose.

I think that STL should be updated to contain the "typename" keyword to
prevent confusion.

Etay.

-- Etay Bogner,
-- Etay_Bogner@mail.stil.scitex.com,
-- Scitex Corp.
-- Israel.
---
[ 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. ]





Author: jason@cygnus.com (Jason Merrill)
Date: 1995/09/24
Raw View
>>>>> Craig P Forbes <craig@mccabe.com> writes:

> My understanding is that the typename keyword may only be used in templates
> to identify subtypes of the template parameters, which otherwise can not be
> identified as a type.

> for example:

> template <T>
> class foo {

>   typename T::i;

This line is semantically null, as the 'typename' keyword only affects the
immediate use of the scope expression, not subsequent uses.

>   int var;

>   void fn() {
>     T::i *var;  //without the typename keyword this could either be a declaration
>                 //or an expression.

This must be 'typename T::i *var;'.

>   }
> };

Jason

[ 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. ]