Re: Re[2]: GCC 3.3 template compile error?
Re: Re[2]: GCC 3.3 template compile error?
- Subject: Re: Re[2]: GCC 3.3 template compile error?
- From: Steve Checkoway <email@hidden>
- Date: Sat, 13 Oct 2007 19:20:23 -0700
On Oct 13, 2007, at 5:05 PM, Peter Mulholland wrote:
template <class T> typename T getAttribute(const xmlpp::Node* node,
const
std::string& attrName) const;
Eww. Does it really accept that? It doesn't look right at all.
Typename should only be required when you have name dependent look up,
or whatever it's called. Something like
template <typename T> void foo( const vector<T> &v )
{
typename vector<T>::const_iterator i = v.begin();
// ...
}
is about the only time I use it.
From the standard, 14.6.2 [temp.res]
A name used in a template declaration or definition and that is
dependent on a template-parameter is assumed not to name a type
unless the applicable name lookup finds a type name or the name is
qualified by the keyword typename.
And from 14.6.3
A qualified-name that refers to a type and that depends on a
template-parameter (14.6.2) shall be prefixed by the keyword
typename to indicate that the qualified-name denotes a type, forming
an elaborated-type-specifier (7.1.5.3).
14.6.6 gives an example
template<class T> struct A {
typedef int B;
A::B b; // ill-formed: typename required before A::B
void f(A<T>::B); // ill-formed: typename required before A<T>::B
typename A::B g(); // OK
};
In OP's case, the return type was the template parameter itself. I
don't think that qualifies as being dependent on the parameter since
you'd otherwise need to write things like:
template<typename T> void foo( typename T t )
{
typename T bar;
// ...
}
and I don't believe that to be correct.
Then again, this standard is anything but clear.
--
Steve Checkoway
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden