473,403 Members | 2,284 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,403 software developers and data experts.

map::iterator error

I have the following:

//-----------------------
typedef std::map<wxString, const void*> MethodMap;
MethodMap mMethods;

const void* hePlugin::GetMethod(const wxString& name) const{
const MethodMap::iterator pos = mMethods.find(name); <== error
if (pos != mMethods.end()){ return pos->second; }
return 0;
}

When I compile this (gcc 3.2.2 on Redhat 9) I get this error for the line
indicated above:

conversion from
`std::_Rb_tree_iterator<std::pair<const wxString, const
void*>, const std::pair<const wxString, const void*>, const
std::pair<const wxString, const void*>*>` to non-scalar type
`std::_Rb_tree_iterator<std::pair<const wxString, const
void*>, std::pair<const wxString, const void*>, std::pair<const wxString,
const void*>*>`

I'm following an example in "The C++ Standard Library: A Tutorial and
Reference" by Josuttis.

I can see that the problem is the missing "const" modifier on the
std::pair's but I don't know how to fix it.

Any help?

--
Benny

(Remove your_rose_colored_glasses to mail me)

Jul 22 '05 #1
3 1474
Benny Hill wrote:
const void* hePlugin::GetMethod(const wxString& name) const{
const*MethodMap::iterator*pos*=*mMethods.find(name );*<==*error


MethodMap::const_iterator*pos*=*mMethods.find(name );

MM


Jul 22 '05 #2
"Benny Hill" wrote:
I have the following:

//-----------------------
typedef std::map<wxString, const void*> MethodMap;
MethodMap mMethods;

const void* hePlugin::GetMethod(const wxString& name) const{
const MethodMap::iterator pos = mMethods.find(name); <== error
if (pos != mMethods.end()){ return pos->second; }
return 0;
}

I'm following an example in "The C++ Standard Library: A Tutorial and
Reference" by Josuttis.

I can see that the problem is the missing "const" modifier on the
std::pair's but I don't know how to fix it.


Use MethodMap::const_iterator instead of const MethodMap::iterator ...

David F
Jul 22 '05 #3
On Wed, 10 Dec 2003 01:05:20 +0100, Max M. wrote:
Benny Hill wrote:
const void* hePlugin::GetMethod(const wxString& name) const{
const*MethodMap::iterator*pos*=*mMethods.find(name );*<==*error


MethodMap::const_iterator*pos*=*mMethods.find(name );

MM


Wow! Less than 15 minutes... Thanks Max and David, this is what I needed!

--
Benny

(Remove your_rose_colored_glasses to mail me)

Jul 22 '05 #4

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

Similar topics

0
by: sks_cpp | last post by:
I am trying to wrap the map iterator for keys and values. However, I seem to run into problems with the values for const_iterator - it works for all other combinations. Below I list my code and...
5
by: Christopher | last post by:
I am having problems iterating through the sequence of objects stored in my std::map I want to call a function from the "value" object in the map. Here is my snippet: typedef std::map<SOCKET,...
5
by: music4 | last post by:
Greetings, I want to STL map class. But I don't know how to use iterator. Let me state my question by following small sample: map<int, int> mymap; // insert some <key,value> in mymap ...
4
by: John | last post by:
I was wondering why the STL RB Tree implementation is used when the iterators of map are incremented/decremented to yield successors and predecessors? This takes O(log n) time (and a lot of memory...
6
by: John | last post by:
I want to store an array of pointers (void *) to iterators inside a map. The idea is to reach the map <key,info> pair faster if the data is in the array. If not use a O(log) search. But stl...
5
by: Bill Oliver | last post by:
Help! I am writing an image processing package. For one constructor, I allow creating an image from a map of points and color values. The points are of a "position" class and the colors are...
2
by: Rakesh Kumar | last post by:
I am encountering the following issue with STL map iterator - wrapped within a template. ( I am wrapping it withing a template since I want to hide the map implementation from the user . At a later...
16
by: xyz | last post by:
I have to run the simulation of a trace file around (7gb contains 116million entries)... presently i am using vector iterators to check the conditions in my program..... it is taking 2 days to...
15
by: puzzlecracker | last post by:
I see that a lot of former in the code, and wonder if there is a technical reason for that
5
by: Micheal Smith | last post by:
I'm looking for a good method to convert a map::iterator to a std::string. I've tried googling for a while, but haven't come up with much. Perhaps I'm kludging things here. Either way any advice...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

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.