Re: Strange template problem - Comeau vs EDG
albrecht.fritzsche schrieb:
What does the standard says about the following
class Base {};
template <typename T>
class Derived : public T
{};
int main() {
Derived<const Base> d;
}
Is this correct Xor not correct?
The strange thing is that Comeau (and gcc and VC++ 8) compiles this
without even a warning while the EDG (and icc) triggers an error. (And
I'd thought Comeau and EDG behaved somewhat the same.)
Unfortunately I cannot find anything in the standard about this issue,
except a little note 14.1(5)
The top-level cv-qualifiers on the template-parameter are ignored when
determining its type.
This very last quote is not related to this issue, because it
concerns only non-type template-parameters.
According to the resolution of the defect report
http://www2.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#484
(which can already be found in the current draft N2134) the intend
is to allow cv qualifiers in typedef-name's.
Further on typedef-name's and type-parameter's are
synchronized according to 14.1/3:
"A type-parameter defines its identifier to be a typedef-name (if
declared with class or typename) or template-name (if declared
with template) in the scope of the template declaration.[..]"
From this we can conclude that your example is feasible
according to the most recent interpretation, which explains
deviations in current compiler reactions.
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]