Topic: Member template classes: allowed?
Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1998/05/04 Raw View
I just tried to do this:
class A
{
public:
template<class T> class X {};
};
and g++ 2.8.0 told me:
invalid member template declaration
Now my questions:
1. Is g++ correct?
2. If yes, why is this illegal? After all, nested classes don't affect
the size of the class, or the size of the virtual function table, so I
don't see any reason for this.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1998/05/05 Raw View
In article C0F57040@physik.tu-muenchen.de, Christopher Eltschka <celtschk@physik.tu-muenchen.de> writes:
>I just tried to do this:
>
>class A
>{
>public:
> template<class T> class X {};
>};
>
>and g++ 2.8.0 told me:
>
>invalid member template declaration
The template rules in the ARM allowed a template declaration only
at file scope.
The C++ draft standard allows templates as members of classes, as in
your example, but I don't know of any compilers that fully support the
feature as yet. (Some compilers support it partially.)
---
Steve Clamage, stephen.clamage@sun.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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Kriang Lerdsuwanakij <lerdsuwa@scf-fs.usc.edu>
Date: 1998/05/05 Raw View
Christopher Eltschka wrote:
>
> I just tried to do this:
>
> class A
> {
> public:
> template<class T> class X {};
> };
>
> and g++ 2.8.0 told me:
>
> invalid member template declaration
The code is correct. The problem is that g++ 2.8.0 does not support
member class templates. Only egcs development snapshot supports it.
--Kriang
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]