 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ivan Godard Guest
|
Posted: Thu Jul 01, 2004 8:45 pm Post subject: Permit "template" qualification to distinguish name-as-templ |
|
|
Extension proposal. Consider:
template<typename X, template struct A{};
template<typename T> struct B : A<T, B> {B(): A<T, ::B>(){} }:
In this context, let us also permit:
template<typename X, template class A{};
template<typename T> struct B : A<T, B> {B(): A<T, template B>(){} }:
There is no machinery extension here, because "template" qualification
already exists; the idiom just lets the compiler choose an interpretation
for "B" as a template rather than the usual interpretation as a type.
Nuisance in the compiler should be minor, and there seems no ambiguity.
The advantage of the proposal shows when struct B is itself declared locally
in another class or namespace; then "::B" must have a proper
name-qualification chain, something like "::Namespace::Struct<T,
U>::Class<V, W>::B" perhaps. This namechain, besides being typically
unreadable, has to be changed whenever the class nesting structure changes,
whereas "template B" does not.
The example arises from actual code using the common "curiously recursive"
use of a derived class as an argument to a templated base class to implement
"mixin"-style interfaces. When the derived is itself a template, then the
base takes a template argument and it is the derived -template- rather than
the particular derived class that must be passed, leading to the example.
Ivan
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|