Rob Williscroft <rt*@freenet.co.uk> wrote in message news:<Xn**********************************@130.133 .1.4>...
Mike Alexeev wrote in news:85**************************@posting.google.c om
in comp.lang.c++:
IIUC the second typename isn't required as typename Y::typeA()
*isn't* a declaration. OTOH I couldn't find a compiler that
rejects it either.
If removing the typename doesn't work with g++ 3.1.1 then use
the above (inline) workaround.
HTH.
Rob.
Rob,
Unfortunately your solution won't work because it is a member function
Sorry I missed that, but my solution was to remove the second typename
which should still work, have you tried it ? does g++ 3.1.1 require the
typename ?, neither of g++ 3.2.2 or g++ 3.4 do.
template and you can not do typedef outside the template. This was my
original problem.
template<class Y>
void f(typename Y::typeA = typename Y::typeA()) {}
If you still need a workaround:
template < typename T >
struct default_arg
{
static value() { return T(); }
};
struct B
{
template < typename Y >
void f(
typename Y::typeA arg = default_arg< typename Y::typeA >::value()
)
{
}
};
Rob.
Rob,
Thanks for the workaround. It works perfectly.
As far as second typename goes G++ 3.1.1 handles it without any
problem. I am going to try it with the 3.4 version as well. It was the
problem with Sun Workshop 6.2 compiler (CC) which I was not able to
compile both with second typename or without it.
Mike