ag******@yahoo.com (David) wrote in message news:<b6**************************@posting.google. com>...
Assuming of course that the instantiation statement is 100% ok.
As a matter of fact, that very instantiation passes successfuly on VC++ 7.1
(and Borland) but since I was suspicious that it was OK there "more by luck
than brain", I checked the same on Linux\GNU were the instantiation failed.
Yes, and this is in fact a very common technique. For instance,
std::vector<T>::vector( size_type, T const& = T(), {default allocator} )
It is impossible to instantiate this member when only the size_type
argument is provided and T doesn't have an accessible default ctor.
Basically templates compile if there is at least one set of arguments
for which they can be instantiated. The reverse is not true; some
errors are too hard to detect without instantiating.
E.g. a template with unsigned integer parameters A,B,C and N that
could only compile if A^(N+3)+B^(N+3)==C^(N+3). A compiler may
reject this, because there is no set of arguments for which this holds
but it isn't required to be aware of the proof to Fermats theorem.
It may instead reject every attempt to instantiate.
Regards,
Michiel Salters