More template issues
1. Multiple explicit specializations.
The Holy Standard tells us, in its glorious ?14.7/5, that no /program/
shall specialize a template more than once for a given set of
template-arguments, but that a compiler doesn't need to diagnose
violations of this rule.
q1A Can it really be correct that (from an in-practice point of view)
explicit specializations can't be placed in header files, and expect the
code to compile with all standard-conforming compilers?
q1B Since inline explicit function specializations are supported, how
about inline explicit function specializations?
2 Referring to a template as template.
In [comp.lang.c++] "Kostas", in the thread "MoreCRTP question", asked
about this code:
template<class T, template <typename> class D>
class Base
{
protected:
Base(T x): i(x) {}
T i;
};
template<class T>
class Derived:public Base<T, Derived>
{
Derived(T x):Base<T, Derived>(x){}
};
Compilers just plain refuse to treat "Derived" as referring to the
template: it's treated as referring to "Derived<T>".
"Zeppe" proposed the following solution:
Derived(T x):Base<T, ::Derived>(x){}
MSVC 7.1 accepts "class" instead of "::".
q2A Is the "::"-qualification standard-conforming in creating a
reference to the template as template, and if it is, how does that work,
exactly?
q2B If it isn't, what's the standard-conforming solution, if one exists?
E.g., Comeau Online doesn't like "template" or "typename" or any such
before "Derived".
q2C What do we call "Derived<T>" (general term)?
3 What's a specialization, formally.
?14.7/4 states that a specialization is a class, function or class
member that is either instantiated or explicitly specialized, where the
previous paragraph effectively defines explicit specialization as
explicit full specialization.
q3A Isn't a partial specialization a specialization?
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]