• 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: Template Bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Template Bug?


  • Subject: Re: Template Bug?
  • From: David Rowland <email@hidden>
  • Date: Fri, 24 Aug 2007 18:38:26 -0700

Willy P wrote:
Not certain that this is the right list to be posting this problem but
here goes:

template< class T >
void createCompilerError()
{
	T::iterator pos;
}


gives me this error: error: expected `;' before 'pos'

I thought that was legal C++ and I have word that it works on MSVC-2005.


This is a somewhat arcane point. "iterator" is a qualified name, dependent on the meaning of T. Since the compiler cannot know the structure of T on first encountering this code, it insists that typenames be called such, using the keyword "typename". You must write it as,


template< class T >
void createCompilerError()
{
	typename T::iterator pos;
}




_______________________________________________ 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: Template Bug?
      • From: "Willy P" <email@hidden>
References: 
 >Template Bug? (From: "Willy P" <email@hidden>)

  • Prev by Date: Re: Template Bug?
  • Next by Date: Re: Template Bug?
  • Previous by thread: Re: Template Bug?
  • Next by thread: Re: Template Bug?
  • Index(es):
    • Date
    • Thread