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

LVL 2
asmyattAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.