This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ template parameter constraints
Alexandre Oliva <aoliva@redhat.com> writes:
| On Jan 30, 2003, Martin Buchholz <martin@xemacs.org> wrote:
|
| > http://m17n.org/martin/writings/template-parameter-constraints.html
|
| > (feedback desired)
|
| /me thinks the syntax for satisfying might be something like Modula3's
| `T1 < T2' constraint, used to indicate that type T1 must be the same
| or derived from T2. We could use something like:
|
| template <class T : predicate<T>::satisfied> declaration;
This has been hashed several times (on the C++ committee reflectors,
at ACCU Spring conferences, with Bjarne Stroustrup, Jeremy Siek,
Fergus Henderson and many others)...
The above doesn't scale to constraints on seperately declared
template-parameters. The last syntaxes Bjarne Stroustrup discussed
were about
template<class T, class U> [predicate<T, V>::holds]
declaration;
Note where the constraints goes (in the square brackets just after the
template-parameters declaration). The above does not conflict with
current grammar, allows for separately declared template-parameters
and works smoothly with other template meta-programming features.
[...]
| Comments?
I'll make more once I'm finished with 3.2.2 issues :-)
-- Gaby