i have map that looks like this:
typedef std::map<PuzzlePartLocation, std::shared_ptr<PuzzleObj>> ComponentsMap;
now i try to set this map with elements via fucntion like this:
void ComponentMadiator::Register(const PuzzlePartLocation puzzlePartLocation,PuzzleObj* puzzleObj)
{
componentsMap[puzzlePartLocation] = std::make_shared<PuzzleObj>(puzzleObj);
}
i just call it like this :
PuzzleObj* pPuzzleObjStickLeft = new PuzzleObj()
pComponentMadiator->Register(1,pPuzzleObjStickLeft );
PuzzleObj contains memeber from type IImageComponent *
PuzzleObj inherits from base class
but it give me error like this :
1>c:\program files\microsoft visual studio 11.0\vc\include\memory(873): error C2664: 'PuzzleObj::PuzzleObj(IImageComponent *)' : cannot convert parameter 1 from 'PuzzleObj *' to 'IImageComponent *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1> c:\program files\microsoft visual studio 11.0\vc\include\memory(972) : see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<PuzzleObj*&>(_V0_t)' being compiled
1> with
1> [
1> _Ty=PuzzleObj,
1> _V0_t=PuzzleObj *&
1> ]
1> c:\program files\microsoft visual studio 11.0\vc\include\memory(972) : see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<PuzzleObj*&>(_V0_t)' being compiled
1> with
1> [
1> _Ty=PuzzleObj,
1> _V0_t=PuzzleObj *&
1> ]
1> d:\dev\cpp\cocos2d-x\cocos2d-x-3.0beta2\cocos2d-x-3.0beta2\projects\neonbreaker\classes\componentmadiator.cpp(23) : see reference to function template instantiation 'std::shared_ptr<_Ty> std::make_shared<PuzzleObj,PuzzleObj*&>(_V0_t)' being compiled
1> with
1> [
1> _Ty=PuzzleObj,
1> _V0_t=PuzzleObj *&
1> ]
std::make_shared<PuzzleObj> creates a new PuzzleObj for you. What you need is std::shared_ptr<PuzzleObj>(puzzleObj).
More importantly
void ComponentMadiator::Register(const PuzzlePartLocation puzzlePartLocation,PuzzleObj* puzzleObj);
should be declared as:
void ComponentMadiator::Register(const PuzzlePartLocation puzzlePartLocation, std::shared_ptr<PuzzleObj> const& puzzleObj);
because it shares ownership of puzzleObj by storing it in the container and that must be communicated in function's interface.
And call it like so:
std::shared_ptr<PuzzleObj> pPuzzleObjStickLeft(std::make_shared<PuzzleObj>());
pComponentMadiator->Register(1, pPuzzleObjStickLeft);
Related
WRT below code, I'm finding compilation issues while, trying to create a thread by calling a member function in another object.
th = std::thread(&AbcSFriend::S2F,this,friendObj);
is the culprit line causing below compilation error. If i remove this line iit compiles fine.
class AbcSFriend
{
public:
void S2F(Abc* ptr)
{}
};
class Abc
{
public:
std::thread th;
AbcSFriend frinedObj;
void FL()
{
th = std::thread(&AbcSFriend::S2F,this,friendObj);
}
};
Cannot generate copy-ctor or copy-assignment operator when UDT
contains a zero-sized array 1>C:\Program Files (x86)\Microsoft Visual
Studio 12.0\VC\include\functional(1149): error C2664: 'eUserErrorCode
std::_Pmf_wrap::operator ()(_Farg0 &,Abc *) const' : cannot convert argument 2 from 'AbcSFriend' to 'Abc *' 1>
with 1> [ 1> _Farg0=AbcSFriend 1> ] 1>
No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called 1> C:\Program
Files (x86)\Microsoft Visual Studio 12.0\VC\include\functional(1137) :
see reference to function template instantiation '_UserErrorCode
std::_Bind,Abc
*,AbcSFriend>::_Do_call<,0x00,0x01>(std::tuple<>,std::_Arg_idx<0x00,0x01>)'
being compiled 1> C:\Program Files (x86)\Microsoft Visual
Studio 12.0\VC\include\functional(1137) : see reference to function
template instantiation '_UserErrorCode
std::_Bind,Abc
*,AbcSFriend>::_Do_call<,0x00,0x01>(std::tuple<>,std::_Arg_idx<0x00,0x01>)'
being compiled 1> C:\Program Files (x86)\Microsoft Visual
Studio 12.0\VC\include\thr/xthread(195) : see reference to function
template instantiation '_UserErrorCode
std::_Bind,Abc
*,AbcSFriend>::operator ()<>(void)' being compiled 1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\thr/xthread(195) : see reference to function template instantiation '_UserErrorCode
std::_Bind,Abc
*,AbcSFriend>::operator ()<>(void)' being compiled 1> C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\thr/xthread(192) : while compiling class template member function 'unsigned int
std::_LaunchPad<_Target>::_Run(std::_LaunchPad<_Target> *)' 1>
with 1> [ 1>
_Target=std::_Bind,Abc
*,AbcSFriend> 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\thr/xthread(187) : see
reference to function template instantiation 'unsigned int
std::_LaunchPad<_Target>::_Run(std::_LaunchPad<_Target> *)' being
compiled 1> with 1> [ 1>
_Target=std::_Bind,Abc
*,AbcSFriend> 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\thr/xthread(205) : see
reference to class template instantiation 'std::_LaunchPad<_Target>'
being compiled 1> with 1> [ 1>
_Target=std::_Bind,Abc
*,AbcSFriend> 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\thread(49) : see
reference to function template instantiation 'void
std::_Launch,Abc
*,AbcSFriend>>(_Thrd_t *,_Target &&)' being compiled 1> with 1> [ 1>
_Target=std::_Bind,Abc
*,AbcSFriend> 1> ] 1> ....\Sources\SOMEPLACESource.cpp(254) : see reference to function
template instantiation 'std::thread::thread(_Fn &&,Abc const
&&,AbcSFriend &)' being compiled 1> with 1> [ 1>
_Fn=eUserErrorCode (__cdecl AbcSFriend:: )(Abc *)
frinedObj (in AbcSFriend frinedObj;)
is not
friendObj (in th = std::thread(&AbcSFriend::S2F,this,friendObj);).
Fix the spelling.
As 'Maxim Egorushkin' says, try:
class AbcSFriend
{
public:
void S2F(class Abc* ptr);
};
class Abc
{
public:
std::thread th;
AbcSFriend friendObj;
void FL()
{
th = std::thread(&AbcSFriend::S2F, &friendObj, this);
}
};
I think the correct order of arguments is:
th = std::thread(&AbcSFriend::S2F, &friendObj, this);
It also makes sense to reverse the order of the declaration of members th and friendObj because currently friendObj destroys before th leaving open a possibility of th using friendObj after friendObj destroyed. Declare friendObj first and th last.
I'm a c++ beginner. I get this warning message in my code:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xmemory(208): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xmemory(280) : see reference to function template instantiation 'void std::allocator<_Ty>::construct<double&>(int *,_Other)' being compiled
1> with
1> [
1> _Ty=int,
1> _Other=double &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(668) : see reference to function template instantiation 'void std::_Cons_val<std::allocator<_Ty>,int,double&>(_Alloc &,_Ty1 *,_Ty2)' being compiled
1> with
1> [
1> _Ty=int,
1> _Alloc=std::allocator<int>,
1> _Ty1=int,
1> _Ty2=double &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(688) : see reference to function template instantiation 'void std::vector<_Ty>::emplace_back<double&>(_Valty)' being compiled
1> with
1> [
1> _Ty=int,
1> _Valty=double &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(675) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::emplace<double&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled
1> with
1> [
1> _Myvec=std::_Vector_val<int,std::allocator<int>>,
1> _Ty=int,
1> _Valty=double &
1> ]
1> preprocessDoc.cpp(14054) : see reference to function template instantiation 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::insert<double&>(std::_Vector_const_iterator<_Myvec>,_Valty)' being compiled
1> with
1> [
1> _Myvec=std::_Vector_val<int,std::allocator<int>>,
1> _Ty=int,
1> _Valty=double &
1> ]
The code compiles without any error however I want to get rid of this warning. The line where I am getting the warning is:
void PreprocessDoc::AddDisplay(double d_display, int pattern)
{
if(pattern==1)
{
d_displayYT.insert(d_displayYT.end(), d_display); //this line
YTtoYrn();
}
}
Any help would be good
_Myvec=std::_Vector_val<int,std::allocator<int>>,
The compiler is telling you that you're converting a double to int. If the double is say 42.666 what is stored is just 42. It's warning you in case this was not intended.
If that's really what you want then do as David suggests. If it's not then you need to change the type the vector holds.
Change:
d_displayYT.insert(d_displayYT.end(), d_display); //this line
to:
d_displayYT.insert(d_displayYT.end(), static_cast<int>(d_display));
This code fails to build in VC2013: (EDIT: I'm not asking why it fails to build)
#include <functional>
struct MyStruct
{
std::function<void()> m_Func;
MyStruct( const std::function<void()>& func) : m_Func(func) {}
};
int main()
{
MyStruct rc( NULL );
return 0;
}
With error:
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\xrefwrap(283): error C2064: term does not evaluate to a function taking 0 arguments
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<int,false>::_ApplyX<_Rx,>(void)' being compiled
1> with
1> [
1> _Ret=void
1> , _Rx=void
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<int,false>::_ApplyX<_Rx,>(void)' being compiled
1> with
1> [
1> _Ret=void
1> , _Rx=void
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(226) : while compiling class template member function 'void std::_Func_impl<_MyWrapper,_Alloc,_Ret,>::_Do_call(void)'
1> with
1> [
1> _Alloc=std::allocator<std::_Func_class<void,>>
1> , _Ret=void
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(495) : see reference to class template instantiation 'std::_Func_impl<_MyWrapper,_Alloc,_Ret,>' being compiled
1> with
1> [
1> _Alloc=std::allocator<std::_Func_class<void,>>
1> , _Ret=void
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Ty=int
1> , _Alloc=std::allocator<std::_Func_class<void,>>
1> , _Fty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(396) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Do_alloc<_Myimpl,_Ty,_Alloc>(_Fty &&,_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Ty=int
1> , _Alloc=std::allocator<std::_Func_class<void,>>
1> , _Fty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Ty=int
1> , _Fty=int
1> , _Alloc=std::allocator<std::_Func_class<void,>>
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(385) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset_alloc<_Ty,std::allocator<std::_Func_class<_Ret,>>>(_Fty &&,_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Ty=int
1> , _Fty=int
1> , _Alloc=std::allocator<std::_Func_class<void,>>
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1> with
1> [
1> _Ret=void
1> , _Ty=int
1> , _Fty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,>::_Reset<_Ty>(_Fty &&)' being compiled
1> with
1> [
1> _Ret=void
1> , _Ty=int
1> , _Fty=int
1> ]
1> f:\work\teststdfunction\teststdfunction.cpp(16) : see reference to function template instantiation 'std::function<void (void)>::function<int>(_Fx &&)' being compiled
1> with
1> [
1> _Fx=int
1> ]
1> f:\work\teststdfunction\teststdfunction.cpp(16) : see reference to function template instantiation 'std::function<void (void)>::function<int>(_Fx &&)' being compiled
1> with
1> [
1> _Fx=int
1> ]
(Note the '_Fx=int' at the last two reported errors).
I can live with that, as changing MyStruct rc(NULL) to MyStruct rc(nullptr) solves the error. Two things however remain a mystery:
1) Removing the const qualifier from MyStruct ctor (MyStruct( std::function<void()>& func) gives a very, very different error:
1>f:\work\main\dev\common\teststdfunction\teststdfunction\teststdfunction.cpp(16):
error C2664: 'MyStruct::MyStruct(const MyStruct &)' : cannot convert
argument 1 from 'int' to 'std::function &'
Which makes more sense than the original error, and now fixing NULL to nullptr doesn't solve it. Why does int (or nullptr) refuse to cast to std::function<>& but agree to cast to a const std::function<>& ?
2) The original code compiles and works as expected in VS2010. Is it an obscure VS2010 library bug?
EDIT:
As far as the const/non const question goes, I now think the casting involved and potential type mismatch are probably a red herring. The argument passed - either NULL or nullptr - is a literal and thus a const. It just cannot bind to a non const reference. For example:
const int& a = 8; // Ok
int& b = 9; // error C2440: 'initializing' : cannot convert from 'int' to 'int &'
Does that sound right? Am I still missing something?
The special here has to do with constructor template constraints and other implicit conversions.
The reason why nullptr works is because std::function has a particular constructor taking it. This constructor will always be the best match for that argument because function templates are ranked as lower preference, all else being equal.
Normally, 0 will implicitly convert to nullptr and that's fine. The problem is that it can also be passed to the unconstrained function template constructor which constructs from function objects. This does not require an implicit conversion, so all is not equal, so this constructor is preferred- which results in the error that you see that int is not a valid function object.
libstdc++ and libc++ don't not exhibit this behaviour because they have implemented the C++14 fix for this problem, which constrains the constructor. C++11 did not so this behaviour is quite conforming for a C++11 implementation.
This kind of issue is why NULL is a terrible thing that you shouldn't use. In fact, the VS2010 team had to rush nullptr out the door as an additional feature in the last minute because NULL interacts so badly with every other feature in C++, ever, and especially with C++11.
For const vs non-const references, other answers have explained that issue adequately.
There are other WTFs you can find when using std::function without the constrained constructor fix shipped in C++14- this isn't the only one. The long and short is that it's a defect in the C++11 Standard, and not in VS. VS2010 compiling it is probably a compiler overload resolution bug.
Casting a T to a U& never works, and that's intentionally. You can cast to a U const&. The reason is that changes to the temporary U object wouldn't propagate back to the T value.
VS2010 is slightly buggy in this respect, and did allow the cast (but with the proper settings, will warn about it)
I'd like to capture a variable of type std::vector<std::unique_ptr<MyClass>> in a lambda expression (in other words, "capture by move"). I found a solution which uses std::bind to capture unique_ptr (https://stackoverflow.com/a/12744730/2478832) and decided to use it as a starting point. However, the most simplified version of the proposed code I could get doesn't compile (lots of template mistakes, it seems to try to call unique_ptr's copy constructor).
#include <functional>
#include <memory>
std::function<void ()> a(std::unique_ptr<int>&& param)
{
return std::bind( [] (int* p) {},
std::move(param));
}
int main()
{
a(std::unique_ptr<int>(new int()));
}
Can anybody point out what is wrong with this code?
EDIT: tried changing the lambda to take a reference to unique_ptr, it still doesn't compile.
#include <functional>
#include <memory>
std::function<void ()> a(std::unique_ptr<int>&& param)
{
return std::bind( [] (std::unique_ptr<int>& p) {}, // also as a const reference
std::move(param));
}
int main()
{
a(std::unique_ptr<int>(new int()));
}
Here's Visual Studio 2012 output:
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\tuple(151): error C2248: 'std::unique_ptr<int,std::default_delete<_Ty>>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<int,std::default_delete<_Ty>>'
1> with
1> [
1> _Ty=int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\memory(1447) : see declaration of 'std::unique_ptr<int,std::default_delete<_Ty>>::unique_ptr'
1> with
1> [
1> _Ty=int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\tuple(521) : see reference to function template instantiation 'std::_Tuple_val<_This>::_Tuple_val<const _Ty&>(_Other)' being compiled
1> with
1> [
1> _This=std::unique_ptr<int,std::default_delete<int>>
1> , _Ty=std::unique_ptr<int,std::default_delete<int>>
1> , _Other=const std::unique_ptr<int,std::default_delete<int>> &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\tuple(521) : see reference to function template instantiation 'std::_Tuple_val<_This>::_Tuple_val<const _Ty&>(_Other)' being compiled
1> with
1> [
1> _This=std::unique_ptr<int,std::default_delete<int>>
1> , _Ty=std::unique_ptr<int,std::default_delete<int>>
1> , _Other=const std::unique_ptr<int,std::default_delete<int>> &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\tuple(521) : while compiling class template member function 'std::tuple<std::unique_ptr<int,std::default_delete<_Ty>>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::tuple(const std::tuple<std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil> &)'
1> with
1> [
1> _Ty=int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\functional(1152) : see reference to function template instantiation 'std::tuple<std::unique_ptr<int,std::default_delete<_Ty>>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::tuple(const std::tuple<std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil> &)' being compiled
1> with
1> [
1> _Ty=int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\functional(1152) : see reference to class template instantiation 'std::tuple<std::unique_ptr<int,std::default_delete<_Ty>>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>' being compiled
1> with
1> [
1> _Ty=int
1> ]
1> main.cpp(15) : see reference to class template instantiation 'std::_Bind<false,void,a::<lambda_2ad08ede4c4ce9c02d5497417b633d1d>,std::unique_ptr<int,std::default_delete<_Ty>>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>' being compiled
1> with
1> [
1> _Ty=int
1> ]
The second argument to bind will be passed to the bound object at the time of call. The problem is that the lambda takes a int*, but the argument is a std::unique_ptr<int> and there is no conversion from the latter to the former.
It should compile (untested) if you change the signature of the lambda to take a std::unique_ptr by reference/const-reference
The problem with the version that passes a lambda taking unique_ptr by reference to std::bind is your conversion to std::function - std::function requires functions to be CopyConstructible ([func.wrap.func.con] p7). Try it without the std::function (Live at ideone):
auto f = std::bind([](std::unique_ptr<int>&){},
std::make_unique<int>());
My understanding of the internals of std::bind is that it will always make a copy of the 1st argument object that is being bound to the function-object rather than moving it (even if that argument is an rvalue), so you'll always end up with a call to the copy-constructor for whatever object you are attempting to bind to the function object, and not the move-constructor, even with the use of std::move.
I'm getting an error occurring in the 'xutility' class - It is locked as I did not create it
error C2582: 'operator =' function is unavailable in 'Agent'
The error points to these lines in the code:
// TEMPLATE FUNCTION move
template<class _InIt,
class _OutIt> inline
_OutIt _Move(_InIt _First, _InIt _Last,
_OutIt _Dest, _Nonscalar_ptr_iterator_tag)
{ // move [_First, _Last) to [_Dest, ...), arbitrary iterators
for (; _First != _Last; ++_Dest, ++_First)
*_Dest = _STD move(*_First); // this line has the error
return (_Dest);
}
Why is this occurring? What does it mean and how can I fix it?
EDIT - this is what I grabbed from the output, can someone help me understand this? Sorry to be a complete newbie...
1>------ Build started: Project: D3D10DEMO, Configuration: Debug Win32 ------
1> Level.cpp
1>c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\level.cpp(449): warning C4018: '<' : signed/unsigned mismatch
1> Brain.cpp
1>c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\brain.cpp(43): warning C4413: 'Brain::nodes' : reference member is initialized to a temporary that doesn't persist after the constructor exits
1> c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\brain.h(34) : see declaration of 'Brain::nodes'
1>c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\brain.cpp(43): warning C4413: 'Brain::roomNodeVectors' : reference member is initialized to a temporary that doesn't persist after the constructor exits
1> c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\brain.h(35) : see declaration of 'Brain::roomNodeVectors'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'Agent'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2535) : see reference to function template instantiation '_OutIt std::_Move<_InIt,_OutIt> (_InIt,_InIt,_OutIt,std::_Nonscalar_ptr_iterator_tag)' being compiled
1> with
1> [
1> _OutIt=Agent *,
1> _InIt=Agent *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1170) : see reference to function template instantiation '_OutIt std::_Move<Agent*,Agent*>(_InIt,_InIt,_OutIt)' being compiled
1> with
1> [
1> _OutIt=Agent *,
1> _InIt=Agent *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1165) : while compiling class template member function 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::erase(std::_Vector_const_iterator<_Myvec>)'
1> with
1> [
1> _Myvec=std::_Vector_val<Agent,std::allocator<Agent>>,
1> _Ty=Agent
1> ]
1> c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\brain.h(41) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=Agent
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2514): error C2582: 'operator =' function is unavailable in 'Pickup'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2535) : see reference to function template instantiation '_OutIt std::_Move<_InIt,_OutIt>(_InIt,_InIt,_OutIt,std::_Nonscalar_ptr_iterator_tag)' being compiled
1> with
1> [
1> _OutIt=Pickup *,
1> _InIt=Pickup *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1170) : see reference to function template instantiation '_OutIt std::_Move<Pickup*,Pickup*>(_InIt,_InIt,_OutIt)' being compiled
1> with
1> [
1> _OutIt=Pickup *,
1> _InIt=Pickup *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(1165) : while compiling class template member function 'std::_Vector_iterator<_Myvec> std::vector<_Ty>::erase(std::_Vector_const_iterator<_Myvec>)'
1> with
1> [
1> _Myvec=std::_Vector_val<Pickup,std::allocator<Pickup>>,
1> _Ty=Pickup
1> ]
1> c:\users\asher\documents\my dropbox\direct3d\d3d10demo_1.0\d3d10demo\brain.h(44) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=Pickup
1> ]
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You seem to be calling a function template of the standard library with a type Agent that cannot be move-assigned to, yet the algorithm invoked needs to do just that.
As Als said in a comment to your question, you need to show the code that invokes this algorithm.
Of course you need to provide the agent class.
Assuming C++11, you need to implement
struct Agent
{
// .... other stuff
Agent(Agent&& other) { /* ... */ }
Agent& operator=(Agent&& other) { /* ... */ return *this; }
};
which is known as the Move Assignment operator. While you're at it, you might want to implement the move constructor as they go hand-in-hand:
Agent(Agent&& other) { /* ... */ }
Recommended reading:
http://en.wikipedia.org/wiki/C%2B%2B11#Rvalue_references_and_move_constructors
http://akrzemi1.wordpress.com/2011/08/11/move-constructor/
and many others