Topic: namespace for templetes
Author: stephen.clamage_nospam@eng.sun.com (Steve Clamage)
Date: 1997/11/25 Raw View
On 21 Nov 97 20:52:40 GMT, Maurizio Vitale
<mav@naxos.esat.kuleuven.ac.be> wrote:
>Alexandre Oliva <oliva@dcc.unicamp.br> writes:
>> Maurizio Vitale writes:
>>
>> > Is the following supposed to be valid C++ according to the final draft?
>>
>> Nope. From the Oct'97 DWP, [temp]
>>
>> 5 A class template shall not have the same name as any other template,
>> class, function, object, enumeration, enumerator, namespace, or type
>> in the same scope (_basic.scope_), except as specified in
>> (_temp.class.spec_).
>
>This matches my Dec'96 draft (the poor student one...).
>Can someone provide some more insight as to why this was done?
It is otherwise too difficult to parse C++ programs, which in turn
means error detection and reporting is unreliable. Consider this
fragment:
X < Y1, Y2 > Z
If X is both a template name and an object name, you can't tell
whether you are looking at a declaration for Z as having a template
type, or a comma-expression with two comparisons. The compiler must in
effect try several ways to parse the code to see if exactly one of
them turns out to be valid. If none of them are valid, it can't know
how to describe the error.
The actual language rule means that the compiler knows by looking only
at X which way to parse the code. Error detection and reporting is
therefore much more reliable.
---
Steve Clamage, stephen.clamage_nospam@eng.sun.com
( Note: remove "_nospam" when replying )
---
[ 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: Maurizio Vitale <mav@naxos.esat.kuleuven.ac.be>
Date: 1997/11/21 Raw View
Alexandre Oliva <oliva@dcc.unicamp.br> writes:
> Maurizio Vitale writes:
>
> > Is the following supposed to be valid C++ according to the final draft?
>
> Nope. From the Oct'97 DWP, [temp]
>
> 5 A class template shall not have the same name as any other template,
> class, function, object, enumeration, enumerator, namespace, or type
> in the same scope (_basic.scope_), except as specified in
> (_temp.class.spec_).
>
This matches my Dec'96 draft (the poor student one...).
Can someone provide some more insight as to why this was done?
Thanks again,
Maurizio
---
[ 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: Maurizio Vitale <mav@naxos.esat.kuleuven.ac.be>
Date: 1997/11/21 Raw View
Is the following supposed to be valid C++ according to the final draft?
template <class T>
struct index {
T t;
};
char* index();
GCC 2.7.3, the latest snapshot of egcs, SunPro 4.1 and Borland 5 all
complain about index being redefined.
Thanks,
Maurizio
---
[ 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/11/21 Raw View
Maurizio Vitale writes:
> Is the following supposed to be valid C++ according to the final draft?
Nope. From the Oct'97 DWP, [temp]
5 A class template shall not have the same name as any other template,
class, function, object, enumeration, enumerator, namespace, or type
in the same scope (_basic.scope_), except as specified in
(_temp.class.spec_).
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
---
[ 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 ]