• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Problem reading iterator values from a set

I am porting some windows C++ code to solaris. The following line of code compiles and works on the windows maching, but not the solaris machine.

I get the following error message:
error: invalid initialization of reference of type 'std::set<std::wstring, std::less<std::wstring>, std::allocator<std::wstring> >&' from expression of type 'const std::set<std::wstring, std::less<std::wstring>, std::allocator<std::wstring> >'

Can anyone shed some light on this? I don't see what the problem is.



set< pair< long,set<wstring> > >::iterator itSet1;
set<wstring> &tempSet = (*itSet1).second;

Open in new window

0
asmyatt
Asked:
asmyatt
  • 2
1 Solution
 
jkrCommented:
Make that

const set<wstring> &tempSet = (*itSet1).second;

and you should be fine (according to the error message).
0
 
jkrCommented:
... or, alternatively

set<wstring> &tempSet = const_cast<set<wstring> >((*itSet1).second);
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now