Topic: type-id instead of class-name
Author: Michael R Cook <mcook@cognex.com>
Date: 1997/03/21 Raw View
Is it valid to use a typedef name (type-id) in place of a class name in a
constructor initializer list?
template <class T> class foo {};
typedef foo<char> bar;
class baz : public bar
{
baz() : bar() {}
};
The dwp seems to say no:
mem-initializer-id:
::opt nested-name-specifieropt class-name
identifier
class-name:
identifier
template-id
/* note: no type-id here */
But that seems like a silly restriction.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: jhs@edg.com (John H. Spicer)
Date: 1997/03/22 Raw View
In article <5gs6dj$i3s$1@erawan.cognex.com> Michael R Cook
<mcook@cognex.com> writes:
>Is it valid to use a typedef name (type-id) in place of a class name in a
>constructor initializer list?
>
> template <class T> class foo {};
> typedef foo<char> bar;
> class baz : public bar
> {
> baz() : bar() {}
> };
>
>The dwp seems to say no:
>
> mem-initializer-id:
> ::opt nested-name-specifieropt class-name
> identifier
> class-name:
> identifier
> template-id
> /* note: no type-id here */
>
>But that seems like a silly restriction.
The syntactic construct "type-id" is not the same as a typedef-name.
A typedef-name that names a class is a class-name, so the answer to your
question is yes, a typedef name may appear as a class name in a constructor
initializer list.
--
John Spicer
Edison Design Group
jhs@edg.com
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Alexandre Oliva <oliva@dcc.unicamp.br>
Date: 1997/03/25 Raw View
Michael R Cook writes:
> Is it valid to use a typedef name (type-id) in place of a class name in a
> constructor initializer list?
Yes, it is. Any name that denotes the base class can be used in the
mem-initializer list. Read [class.base.init] paragraph 2.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
Universidade Estadual de Campinas, SP, Brasil
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]