vector insert() warning message - c++

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));

Related

MSVC: Can't create a std::variant of std::boyer_moore_searcher

I'm trying to get my code that compiles on Linux to be compatible with Windows. Here is a simplification of my situation (I have a variant of more than one type in the real situation.):
#include "stdafx.h"
#include <variant>
#include <functional>
#include <string>
using namespace std;
auto searcher(const string& s) {
return boyer_moore_searcher(s.begin(), s.end());
}
int main()
{
string pattern = "ABC";
variant<decltype(searcher(""))> v{ searcher(pattern) };
}
When I compile with MSVC 2017, I get the following error:
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\functional(2603): error C2440: 'initializing': cannot convert from 'const std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>>' to 'void *'
1> with
1> [
1> _Ty=char
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\functional(2603): note: 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\2017\community\vc\tools\msvc\14.14.26428\include\functional(2601): note: while compiling class template member function 'std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>>::boyer_moore_searcher(const std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>> &) noexcept'
1> with
1> [
1> _Ty=char
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\variant(537): note: see reference to function template instantiation 'std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>>::boyer_moore_searcher(const std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>> &) noexcept' being compiled
1> with
1> [
1> _Ty=char
1> ]
1>d:\users\narut\source\repos\consoleapplication2\consoleapplication2\consoleapplication2.cpp(12): note: see reference to class template instantiation 'std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>>' being compiled
1> with
1> [
1> _Ty=char
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\functional(2603): error C2439: 'std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>>::_Data': member could not be initialized
1> with
1> [
1> _Ty=char
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\functional(2629): note: see declaration of 'std::boyer_moore_searcher<std::_String_const_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::hash<char>,std::equal_to<void>>::_Data'
1> with
1> [
1> _Ty=char
1> ]
The same code compiles with the libstdc++ implementation on gcc. I tried libc++ experimental with clang and it also compiles. Is this a MSVC implementation bug or is there no C++ standard that requires variant to work with this particular class?

std thread sleep_for doesnt work with some chrono::duration

I am using VS2012 and I have problem with following example:
#include <chrono>
#include <thread>
int main()
{
// doesn't compile and I don't understand why:
std::this_thread::sleep_for(std::chrono::duration<double>(0.1));
// I can use this but still I would like to know the reason:
std::this_thread::sleep_for(std::chrono::duration<long long, std::milli>(100));
return 0;
}
Both duration should be valid. And it is possible to use them in different context.
Compile error:
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\chrono(749): error C2679: binary '+=' : no operator found which takes a right-hand operand of type 'const std::chrono::duration<_Rep>' (or there is no acceptable conversion)
1> with
1> [
1> _Rep=double
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\chrono(166): could be 'std::chrono::duration<_Rep,_Period> &std::chrono::duration<_Rep,_Period>::operator +=(const std::chrono::duration<_Rep,_Period> &)'
1> with
1> [
1> _Rep=__int64,
1> _Period=std::nano
1> ]
1> while trying to match the argument list '(std::chrono::nanoseconds, const std::chrono::duration<_Rep>)'
1> with
1> [
1> _Rep=double
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\thread(164) : see reference to function template instantiation 'xtime std::_To_xtime<double,std::ratio<_Nx>>(const std::chrono::duration<_Rep> &)' being compiled
1> with
1> [
1> _Nx=0x01,
1> _Rep=double
1> ]
1> i:\prog\.c++\test2\test2\source.cpp(13) : see reference to function template instantiation 'void std::this_thread::sleep_for<double,std::ratio<_Nx>>(const std::chrono::duration<_Rep> &)' being compiled
1> with
1> [
1> _Nx=0x01,
1> _Rep=double
1> ]
1>
1>Build FAILED.
Any help appreciated.
It is VS2012 compiler issue. Not 100% sure if it is this one (thx Praetorian). But it is possible to compile without problem with gcc 4.9.2. I should've think about trying it before I ask.

Failure when casting NULL/nullptr to std::function<>&

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)

Extracting unique, case insensitive strings from a vector using std::unique_copy

The Problem
Consider the following vectors:
std::vector<std::string> extensions;
extensions.push_back(".cpp");
extensions.push_back(".CPP");
extensions.push_back(".h");
extensions.push_back(".H");
std::vector<std::string> caselessUniqueExtensions;
Copy the contents of extensions into caselessUniqueExtensions, but discard all unique extensions, ignoring case. (I.e. the result should have two elements - one of either .cpp or .CPP, and one of either .h and .H.)
The Question
There are obviously many ways to do this, some more effecient than others, and some more readable than others. One such way I thought may work is the following:
#include <boost/algorithm/string/compare.hpp>
...
std::unique_copy(
extensions.begin(), extensions.end(),
caselessUniqueExts.begin(),
boost::is_iequal());
However, it fails to compile using MSVS2010:
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(626): error C2440: 'type cast' : cannot convert from 'unsigned char' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2211) : see reference to function template instantiation '_Elem std::_Maklocchr<_Elem>(char,_Elem *,const std::_Locinfo::_Cvtvec &)' being compiled
1> with
1> [
1> _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2210) : while compiling class template member function 'std::basic_string<_Elem,_Traits,_Ax> std::ctype<std::basic_string<_Elem,_Traits,_Ax>>::do_widen(char) const'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\locale(261) : see reference to class template instantiation 'std::ctype<_Elem>' being compiled
1> with
1> [
1> _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\locale(259) : see reference to function template instantiation '_Elem std::toupper<T1>(_Elem,const std::locale &)' being compiled
1> with
1> [
1> _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>,
1> T1=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(2042) : see reference to function template instantiation 'bool boost::algorithm::is_iequal::operator ()<std::basic_string<_Elem,_Traits,_Ax>,std::basic_string<_Elem,_Traits,_Ax>>(const T1 &,const T2 &) const' being compiled
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>,
1> T1=std::basic_string<char,std::char_traits<char>,std::allocator<char>>,
1> T2=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(2070) : see reference to function template instantiation '_OutIt std::_Unique_copy<_InIt,_OutIt,_Pr>(_FwdIt,_FwdIt,_OutIt,_Pr,std::forward_iterator_tag)' being compiled
1> with
1> [
1> _OutIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1> _InIt=std::basic_string<char,std::char_traits<char>,std::allocator<char>> *,
1> _Pr=boost::algorithm::is_iequal,
1> _FwdIt=std::basic_string<char,std::char_traits<char>,std::allocator<char>> *
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(2094) : see reference to function template instantiation '_OutIt std::_Unique_copy1<std::basic_string<_Elem,_Traits,_Ax>*,_OutIt,_Pr>(_InIt,_InIt,_OutIt,_Pr,std::tr1::true_type)' being compiled
1> with
1> [
1> _OutIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>,
1> _Pr=boost::algorithm::is_iequal,
1> _InIt=std::basic_string<char,std::char_traits<char>,std::allocator<char>> *
1> ]
1> c:\users\stv04463\documents\visual studio 2010\projects\pgp sandbox\pgp sandbox\main.cpp(64) : see reference to function template instantiation '_OutIt std::unique_copy<std::_Vector_iterator<_Myvec>,std::_Vector_iterator<_Myvec>,boost::algorithm::is_iequal>(_InIt,_InIt,_OutIt,_Pr)' being compiled
1> with
1> [
1> _OutIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1> _Myvec=std::_Vector_val<std::string,std::allocator<std::string>>,
1> _InIt=std::_Vector_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
1> _Pr=boost::algorithm::is_iequal
1> ]
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(593): error C2440: 'type cast' : cannot convert from 'std::basic_string<_Elem,_Traits,_Ax>' to 'unsigned char'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
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 10.0\vc\include\xlocale(2229) : see reference to function template instantiation 'char std::_Maklocbyte<std::basic_string<_Elem,_Traits,_Ax>>(std::basic_string<_Elem,_Traits,_Ax>,const std::_Locinfo::_Cvtvec &)' being compiled
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xlocale(2225) : while compiling class template member function 'char std::ctype<_Elem>::_Donarrow(_Elem,char) const'
1> with
1> [
1> _Elem=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
Am I missing some basic understanding here, or should it not be possible to combine std::unique_copy with boost::is_iequal?
I am aware of the alternatives - I'd like to know why I'm getting this compiler error.
The boost::is_iequal predicate is meant to be used on single characters, not on an entire string like you're doing.
Unfortunately the Boost String Algorithms documentation is not the best, but you can see this specified here: "Defines element comparison predicates", where "element" refers to the string characters.
Internally, boost::is_iequal calls std::toupper on its arguments, and this can only work on characters.

error C2582: 'operator =' function is unavailable. (xutility)

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