• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re[2]: GCC 3.3 template compile error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re[4]: GCC 3.3 template compile error?
      • From: Peter Mulholland <email@hidden>
References: 
 >GCC 3.3 template compile error? (From: "Tim Conkling" <email@hidden>)
 >Re: GCC 3.3 template compile error? (From: "Clark Cox" <email@hidden>)
 >Re: GCC 3.3 template compile error? (From: "Tim Conkling" <email@hidden>)
 >Re[2]: GCC 3.3 template compile error? (From: Peter Mulholland <email@hidden>)

  • Prev by Date: Re[2]: GCC 3.3 template compile error?
  • Next by Date: Re[4]: GCC 3.3 template compile error?
  • Previous by thread: Re[2]: GCC 3.3 template compile error?
  • Next by thread: Re[4]: GCC 3.3 template compile error?
  • Index(es):
    • Date
    • Thread