Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error using STL function copy

0 views
Skip to first unread message

arkady....@gmail.com

unread,
Dec 28, 2008, 10:18:04 AM12/28/08
to
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

g3r...@gmail.com

unread,
Dec 28, 2008, 2:53:27 PM12/28/08
to

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

Fraser Ross

unread,
Dec 29, 2008, 8:37:38 AM12/29/08
to
Are you using an associative container?

Fraser.


Vaclav Haisman

unread,
Dec 29, 2008, 6:51:54 AM12/29/08
to
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.

--
VH

SG

unread,
Dec 29, 2008, 3:37:32 PM12/29/08
to
On 28 Dez., 16:18, arkady.karp...@gmail.com wrote:
> 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

SG

unread,
Dec 29, 2008, 3:55:22 PM12/29/08
to
On 29 Dez., 21:37, SG <s.gesem...@gmail.com> wrote:
> 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

0 new messages