Error using STL function copy

A

arkady.karpman

Hello,

During compilation of code :
std::copy(AgentID_To_AgentStruct.begin(),AgentID_To_AgentStruct.end
(),Local_AgentID_To_AgentStruct.begin());

I got error

Error 125 error C2582: 'operator =' function is unavailable in
'std::pair<_Ty1,_Ty2>' D:\Program Files\Microsoft Visual Studio 8\VC
\include\xutility 2266

I am using VC7++.

Thanks

Arkady
 
G

g3rc4n

Hello,

During compilation of code :
std::copy(AgentID_To_AgentStruct.begin(),AgentID_To_AgentStruct.end
(),Local_AgentID_To_AgentStruct.begin());

I got error

Error   125     error C2582: 'operator =' function is unavailable in
'std::pair<_Ty1,_Ty2>'    D:\Program Files\Microsoft Visual Studio 8\VC
\include\xutility       2266

I am using VC7++.

Thanks

Arkady

sounds like something can't be copied, overload operator= for the
elements of Local_AgentID_To_AgentStruct
 
V

Vaclav Haisman

Hello,

During compilation of code :
std::copy(AgentID_To_AgentStruct.begin(),AgentID_To_AgentStruct.end
(),Local_AgentID_To_AgentStruct.begin());

I got error

Error 125 error C2582: 'operator =' function is unavailable in
'std::pair<_Ty1,_Ty2>' D:\Program Files\Microsoft Visual Studio 8\VC
\include\xutility 2266
This is not enough information to diagnose what is the problem. At least
provide the types of AgentID_To_AgentStruct and Local_AgentID_To_AgentStruct.
I am using VC7++.
I do not think you are using VC7 or VC7.1. The path in the pasted error says
you are using VC8.
 
S

SG

During compilation of code :
std::copy(AgentID_To_AgentStruct.begin(),AgentID_To_AgentStruct.end
(),Local_AgentID_To_AgentStruct.begin());

I got error

Error   125     error C2582: 'operator =' function is unavailable in
'std::pair<_Ty1,_Ty2>'    D:\Program Files\Microsoft Visual Studio 8\VC
\include\xutility       2266

You really have to provide some more infos. I'm guessing that
AgentID_To_AgentStruct and Local_AgentID_To_AgentStruct are maps of
some sort. This would explain that "std::pair<_Ty1,_Ty2>". However,
the elements of a map are NOT assignable. The key is const which is
why your compiler complained.

If you want to copy the map simply write

map2 = map1;

If you want to add the pairs from one map to the other you can do this
via

#include <iterator>

copy(map1.begin(), map1.end(),
std::inserter(map2,map2.begin()) );

Cheers!
SG
 
S

SG

If you want to add the pairs from one map to the other you can do this
via

   #include <iterator>

   copy(map1.begin(), map1.end(),
        std::inserter(map2,map2.begin()) );

or better yet:

map2.insert(map1.begin(), map1.end());

;-)

Cheers!
SG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top