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 4 2383
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
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.
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 <ra******@t-online.de> wrote in message news:<d1*************@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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sergei |
last post by:
I ran into this problem. I needed to create an entry for access to a
library
of functions that are "extern C", and I just can't find the right syntax, if
it exists at all ( I am using MSVC...
|
by: Gianni Mariani |
last post by:
I remember seeing a neat template specialization trick posted here a few
months ago that allowed the detection of a type containing a member.
After a day searching through google archives I come up...
|
by: Jef Driesen |
last post by:
I need to implement a function to implement the rounding of floating point
values. At the moment i have two different implementations, depending on the
type of the return value (integer or double)....
|
by: Mat DeLong |
last post by:
Can someone explain this error to me? :
main.cpp:9: instantiated from `void show(const LIST::List<T>&) '
main.cpp:23: instantiated from here
list.cpp:58: error: dependent-name...
|
by: Ann Huxtable |
last post by:
I have the following code segment - which compiles fine. I'm just
worried I may get run time probs - because it looks like the functions
are being overloaded by the return types?. Is this Ok: ?
...
|
by: Joel Kullberg |
last post by:
Hi!
I have a question for u guys!
I would like to use the c++ package ITK (www.itk.org) for internal handling och data and functions in a dataset3D class of mine!
I also want to use a base...
|
by: Kobe |
last post by:
Is there any difference in:
template <class T>
vs.
template <typename T>
?
|
by: William |
last post by:
for example, I have a global object:
extern Object myobj;
Can gcc get this object by using string "myobj" at runtime??
I know C++ rtti doesnt support this,
but I dont know if gcc can ,
...
|
by: Ed |
last post by:
Hi, guys,
Here is a simple template class definition:
template <typename T = int>
class Point {
public:
T X;
T Y;
T Z;
};
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |