xlc - A template dependent name that is a type must be qualified with "typename"



 DEVELOP > c-Plus-Plus > xlc - A template dependent name that is a type must be qualified with "typename"

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "pervinder"
Date: 21 Mar 2005 11:07:14 PM
Object: xlc - A template dependent name that is a type must be qualified with "typename"
Hi,
I get an error on line #3 while compiling the program segment on aix
(xlc - va6)
While this warning is not seen with gcc
"test.cpp" line 200.18: 1540-0152 (W) A template dependent name that
is a type must be qualified with "typename".
#1 template<class KeyType,
class ValueType, ....>
#2 class Iterator;
#3 friend class Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;
Does anyone has a hint for this behaviour ?
R/s
pervinder
.

User: "Malte Starostik"

Title: Re: xlc - A template dependent name that is a type must be qualifiedwith "typename" 21 Mar 2005 11:53:06 PM
pervinder schrieb:

Hi,
I get an error on line #3 while compiling the program segment on aix
(xlc - va6)
While this warning is not seen with gcc

gcc has been warning about this since version 3.0. Anything before that
is totally outdated (current version is 3.4.3 and 4.0 is due soon...)

"test.cpp" line 200.18: 1540-0152 (W) A template dependent name that
is a type must be qualified with "typename".


#1 template<class KeyType,
class ValueType, ....>
#2 class Iterator;
#3 friend class Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;

Does anyone has a hint for this behaviour ?

As the warning says, types that depend on a template parameter must be
qualified with the typename keyword:
friend class typename Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;
This way, you tell the compiler that
Cpp_SortedList<KeyType,ValueType,.....> :: Iterator is a type and not a
data member or member function.
template< typename T >
struct Foo
{
std::vector< int >::iterator it1;
// fine, std::vector< int > does not depend on T
std::vector< T >::iterator it2;
// error, std::vector< T > depends on T
typename std::vector< T >::iterator it3;
// fine, typename used
};
Cheers,
Malte
.
User: "Rolf Magnus"

Title: Re: xlc - A template dependent name that is a type must be qualified with "typename" 22 Mar 2005 06:06:34 AM
Malte Starostik wrote:

pervinder schrieb:

Hi,
I get an error on line #3 while compiling the program segment on aix
(xlc - va6)
While this warning is not seen with gcc


gcc has been warning about this since version 3.0. Anything before that
is totally outdated (current version is 3.4.3 and 4.0 is due soon...)

"test.cpp" line 200.18: 1540-0152 (W) A template dependent name that
is a type must be qualified with "typename".


#1 template<class KeyType,
class ValueType, ....>
#2 class Iterator;
#3 friend class Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;

Does anyone has a hint for this behaviour ?


As the warning says, types that depend on a template parameter must be
qualified with the typename keyword:

friend class typename Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;

....although it looks strange in this particular place. I mean, you already
said "class", so what could that class be, other than a type? I guess it's
just needed here to make the rules simpler.
.
User: "pervinder"

Title: Re: xlc - A template dependent name that is a type must be qualified with "typename" 28 Mar 2005 10:07:05 PM
The typename did not work, compiler generates the same warnings again
The Cpp_SortedList is defined as below :-
template<class KeyType,
class ValueType,
class LessThan = less<KeyType>,
class MemoryBase = Cpp_CachedSmallObject

class Cpp_SortedList : public MemoryBase

{
protected: ,,,
,,,,,,,,,,,,,,,,,
}
R/s
pervinder
Rolf Magnus <ramagnus@t-online.de> wrote in message news:<d1p1lb$eso$04$1@news.t-online.com>...

Malte Starostik wrote:

pervinder schrieb:

Hi,
I get an error on line #3 while compiling the program segment on aix
(xlc - va6)
While this warning is not seen with gcc


gcc has been warning about this since version 3.0. Anything before that
is totally outdated (current version is 3.4.3 and 4.0 is due soon...)

"test.cpp" line 200.18: 1540-0152 (W) A template dependent name that
is a type must be qualified with "typename".


#1 template<class KeyType,
class ValueType, ....>
#2 class Iterator;
#3 friend class Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;

Does anyone has a hint for this behaviour ?


As the warning says, types that depend on a template parameter must be
qualified with the typename keyword:

friend class typename Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;


...although it looks strange in this particular place. I mean, you already
said "class", so what could that class be, other than a type? I guess it's
just needed here to make the rules simpler.

.
User: "Malte Starostik"

Title: Re: xlc - A template dependent name that is a type must be qualifiedwith "typename" 28 Mar 2005 10:40:53 PM
pervinder schrieb:

The typename did not work, compiler generates the same warnings again
The Cpp_SortedList is defined as below :-

template<class KeyType,
class ValueType,
class LessThan = less<KeyType>,
class MemoryBase = Cpp_CachedSmallObject

class Cpp_SortedList : public MemoryBase

{
protected: ,,,
,,,,,,,,,,,,,,,,,
}

friend class typename Cpp_SortedList<KeyType,ValueType,.....> :: Iterator;

Only now I see it's a friend declaration...how is Cpp_SortedList< ...

::Iterator declared? If it's a typedef you can't befriend it :-(

Any chance you could provide a minimal but complete example that
produces the problem?
Cheers,
Malte
.





  Page 1 of 1

1

 


Related Articles
Class members that MUST be initialized by temporary objects in amember initialization list
How can I insure that the objects of a class must be allocated in the heap?
Re: verify that a file exist!
Re: Classes that refer to each other
Given a date, how to find the beginning date and ending date of that week
Creating a file that doesn't exist
Specialisation of a template that results to another template
Java's performance far better that optimized C++
What API replaces the unlock API that existed in gcc 2.9.3?
Re: C/C++ compiler that will work with Atmel STK500
How to do that ?
Class with method that returns different pointer depending on implementation?
operator*(Foo) and operator*(int) const: ISO C++ says that these are ambiguous:
User-defined manipulators that accept arguments
How to make a library that comples the users to define some function
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER