Re: Default typed argument for a templated argument
* Olivier:
Anyway, my real question has to do with the fact that MSVC and GCC are
very happy to compile the 'func' definition despite the fact that you
can't use it relying on the default argument. Why is that ?
Only the compiler developers could answer that, it's a Quality Of
Implementation
issue.
Consider a perhaps more subtle case, where the presence of a default
argument in
one member routine makes another member routine effectively inaccessible:
struct Foo
{
Foo() {} // No way to use this constructor!
Foo( int = 0 ) {}
};
int main()
{
Foo( 42 ); // OK.
Foo(); // Ouch! Ambiguous!
}
It's very difficult to draw the line about what to warn about, because
someone's
slip-up can easily be someone else's intended effect. Consider e.g. warning
about unreachable code, when the intent is a compile time configuration of
what
code should be present. But I agree that it's even more difficult to imagine
a
valid usage of a default that can never be invoked, or a member routine
definition that can never be invoked, so, perhaps report this to the
vendors?
Cheers & hth.,
- Alf
--
Due to hosting requirements I need visits to <url:
http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]