By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

map::iterator error

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.