• 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: type/value mismatch error in template
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: type/value mismatch error in template


  • Subject: Re: type/value mismatch error in template
  • From: Andreas Grosam <email@hidden>
  • Date: Wed, 12 Oct 2005 21:33:48 +0200


On 12.10.2005, at 17:57, John Weeks wrote:

I posted this a couple days ago, and it looks like it didn't get noticed.
Sorry to re-post, but it's got me stumped and stopped.


I successfully compiled this snippet (without warnings) with
compiler: powerpc-apple-darwin8-g++-4.0.0 (GCC), build 5026 (this is XCode 2.2 DP 1)

#include <vector>
#include <utility>

using namespace std;

template <class T> void foo()
{
typename vector<T>::iterator iter; // not used
pair<typename vector<T>::iterator, typename vector<T>::iterator> p;
vector<T> vec;
p.first = vec.begin();
p.second = vec.end();
}

int main()
{
foo<char>();
return 0;
}


(Omitting using namespace declaration and adding full qualified names yields the same result.)


Which compiler are you using?


Andreas

Xcode 2.1 gives the following errors:

error: expected `;' before 'iter'
error: type/value mismatch at argument 1 in template parameter list for
'template<class _T1, class _T2> struct std::pair'
error: expected a type, got
'std::vector<VectorT,std::allocator<_CharT> >::iterator'
type/value mismatch at argument 2 in template parameter list for
'template<class _T1, class _T2> struct std::pair'
expected a type, got 'std::vector<VectorT,std::allocator<_CharT> >::iterator'

in compiling this code (error lines marked with *)

template <class T> int
RunningMedianTFP(T *dataP, IndexInt stride,IndexInt nstrides,IndexInt
num,int replaceMedianWithValue,T replacementValue,T replacementThreshold)
{
int i, err= 0;
IndexInt oldDataIndex;
T valueToRemove, valueToAdd;
T *p;
* typename vector<T>::iterator iter;
* pair<typename vector<T>::iterator, typename vector<T>::iterator> range;

It looks like gcc is not recognizing "typename vector<T>::iterator" as a
type. I expect we're running afoul of two-phase name lookup, but I was
under the impression that "typename" should have taken care of that.

"vector<double>::iterator iter" compiles OK.

The code above compiles OK with CodeWarrior with the ISO Template Parsing
checkbox turned on.

Thanks in advance, and I apologize for the munged lines that are going to
result from those long lines.

Regards,
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
email email@hidden
_______________________________________________
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

 _______________________________________________
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

References: 
 >type/value mismatch error in template (From: John Weeks <email@hidden>)

  • Prev by Date: Re: type/value mismatch error in template
  • Next by Date: Symbol coloring in XCode?
  • Previous by thread: type/value mismatch error in template
  • Next by thread: Re: type/value mismatch error in template
  • Index(es):
    • Date
    • Thread