| /*
See the even simpler program below.
You've hit a touchy area of the C++ language,
i.e. whether default constructors must be supplied
for arguments used in default template argument
declarations.
This is currently a hot topic in the ANSI
C++ committee, since most current implementations
of the STL (including ours) heavily rely
on the answer being no. At the last meeting
some wording was added to the library section
which said:
"Throughout the C++ Library clauses (17 through 27)
whenever a template member function is declared with one or
more default arguments, this is to be understood as
specifying a set of two or more overloaded template
member functions. ..."
At the next C++ standards meeting (in a couple of weeks) the
issue of whether the compiler should have to
accept the program below OR whether all the
STL library declarations that face this problem
should have to be changed to a set of overloaded
declarations, i.e.:
// this would have be changed:
vector(int n, const T& value = T()) {;}
// to:
vector(int n);
vector(int n, const T& value);
For now, cxx obviously should not give an internal error
here. It should either accept the program or give an error
that the A::nested() ctor declaration is missing. I'm not
sure why there's only a problem if the template argument
has a destructor declaration. But as you can see below,
it has nothing to do with the fact that you're using
a nested type.
In the meantime you can either supply the A::nested ctor
or break up the vector ctor declaration into a set of
overloaded declarations as described above.
*/
template <class T>
struct vector {
vector(int n, const T& value = T()) {;}
};
class A {
~A();
};
void main()
{
vector<A> vec(1);
}
|