473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Defining iterators

I upgraded to gcc 3.4 and ran into the problem below. I don't understand
it and need to fix this quickly. Any resolutions in changing to code
will be appreciated. I will research this later this week as time allows
but a quick resolution with code example will help a great deal.

Thanks

-------------

crt/crtmap.hpp:17: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:17: error: ISO C++ forbids declaration of `iterator' with
no type

crt/crtmap.hpp:17: error: expected `;' before "iterator"

crt/crtmap.hpp:18: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:18: error: ISO C++ forbids declaration of
`const_iterator' with no type

crt/crtmap.hpp:18: error: expected `;' before "const_iterator"

------

template <class K,class D,class C>
class CRTMap
{

private:
mutable std::map<K,D,C> mymap;
mutable CRTMLock MLock;

public:
typedef std::map<K,D,C>::iterator iterator; // line 17
typedef std::map<K,D,C>::const_iterator const_iterator; // line 18
Jul 22 '05 #1
2 2008
Deke wrote:

I upgraded to gcc 3.4 and ran into the problem below. I don't understand
it and need to fix this quickly. Any resolutions in changing to code
will be appreciated. I will research this later this week as time allows
but a quick resolution with code example will help a great deal.

Thanks

-------------

crt/crtmap.hpp:17: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:17: error: ISO C++ forbids declaration of `iterator' with
no type

crt/crtmap.hpp:17: error: expected `;' before "iterator"

crt/crtmap.hpp:18: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:18: error: ISO C++ forbids declaration of
`const_iterator' with no type

crt/crtmap.hpp:18: error: expected `;' before "const_iterator"

------

template <class K,class D,class C>
class CRTMap
{

private:
mutable std::map<K,D,C> mymap;
mutable CRTMLock MLock;

public:
typedef std::map<K,D,C>::iterator iterator; // line 17
typedef std::map<K,D,C>::const_iterator const_iterator; // line 18

It's become quite a FAQ that is not yet in The FAQ.

Must use typename with dependent type names:
typedef typename std::map<K,D,C>::iterator iterator; // line 17
typedef typename std::map<K,D,C>::const_iterator const_iterator; // line 18

(the older compiler versions were slacking on the standard)

Denis
Jul 22 '05 #2
"Denis Remezov" <RE*********************@yahoo.removethis.ca> wrote in
message news:40***************@yahoo.removethis.ca...
It's become quite a FAQ that is not yet in The FAQ.

Must use typename with dependent type names:
typedef typename std::map<K,D,C>::iterator iterator; // line 17 typedef typename std::map<K,D,C>::const_iterator const_iterator; // line 18
(the older compiler versions were slacking on the standard)


The standard *did* change underfoot, you know.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Steven Bethard | last post by:
So, as I understand it, in Python 3000, zip will basically be replaced with izip, meaning that instead of returning a list, it will return an iterator. This is great for situations like: zip(*)...
18
by: deancoo | last post by:
I have gotten into the habit of often using copy along with an insert iterator. There are scenarios where I process quite a lot of data this way. Can someone give me a general feel as to how much...
1
by: Marcin Kaliciñski | last post by:
template<class RanAccIt> void some_algorithm(RanAccIt begin, RanAccIt end) { // this algorithm involves calling std::lexicographical_compare // on range [begin, end), and on reverse of this range...
3
by: codefixer | last post by:
Hello, I am trying to understand if ITERATORS are tied to CONTAINERS. I know the difference between 5 different or 6(Trivial, on SGI). But what I fail to understand is how can I declare all 5...
8
by: babak | last post by:
Hi everyone I have a problem with Iterators and containers in STL that hopefully someone can help me with. This is what I try to do: I have an associative (map) container and I have a...
24
by: Lasse Vågsæther Karlsen | last post by:
I need to merge several sources of values into one stream of values. All of the sources are sorted already and I need to retrieve the values from them all in sorted order. In other words: s1 = ...
14
by: Jiri Kripac | last post by:
Languages such as Simula 67 contain a general concept of coroutines that allow the execution of a method to be suspended without rolling back the stack and then later resumed at the same place as...
19
by: John | last post by:
In STL's map implementation, the distance between two iterators it1, it2 takes O(K) to compute where K is the actual distance between the two iterators. In theory, a red black tree can do this...
2
by: ma740988 | last post by:
typedef std::vector < std::complex < double > > complex_vec_type; // option1 int main() { complex_vec_type cc ( 24000 ); complex_vec_type dd ( &cc, &cc ); } versus
18
by: desktop | last post by:
1) I have this code: std::list<intmylist; mylist.push_back(1); mylist.push_back(2); mylist.push_back(3); mylist.push_back(4);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.