RE: template args

{ Edits: "Subject" header corrected, was "subject", and banner area contents
corrected. Please note that articles with malformed headers cause problems and
will not necessarily be propagated by Usenet servers. Using a different Usenet
client, or simply using a Usenet client, might cure the problem. -mod }

Hi,

1.

I have a syntax question (I am not trying to write container independent
code). I would like to specify a container and its type, as for
example,
"something" where the "int" would be passed to the "vector".
However, I can't get the syntax right, as apparently the default
arguments,
i.e., allocator in the code below, is ignored.
It seems that U is wrong, as U has to have two arguments. However,
one
of them should be automatically deduced. Nevertheless it doesn't
compile.

------------------------------------------------------------------------
-

#include
#include


template
> class U>
class wrapper
{
U holder; // doesn't compile!
public:
size_t size() { return holder.size(); }
};


int main()
{
wrapper intVec;
intVec.size();

wrapper intlist;
intVec.size();

return 0;
}
------------------------------------------------------------------------
-
2.
Or even take this simple example:

How can one avoid specifying arguments in declaration of variable v_ ?

template class X1 { };

template class U = X1> class X2 { };
int main(int, char**)
{
X2<> v_; // use default parameters
}


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Google