The code sample fails to compile with the following error message:
1>------ Build started: Project: cpptest, Configuration: Debug x64 ------
1> test.cpp
1>test.cpp(13): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xrefwrap(435): could be 'std::tr1::reference_wrapper<_Ty> &std::tr1::reference_wrapper<_Ty>::operator =(const std::tr1::reference_wrapper<_Ty> &)'
1> with
1> [
1> _Ty=int
1> ]
1> while trying to match the argument list '(std::tr1::reference_wrapper<_Ty>, int)'
1> with
1> [
1> _Ty=int
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxcallobj(13) : see reference to function template instantiation 'void Foo::operator ()<_Arg>(T &)' being compiled
1> with
1> [
1> _Arg=std::tr1::reference_wrapper<int>,
1> T=std::tr1::reference_wrapper<int>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxbind1(292) : see reference to function template instantiation '_Ret std::tr1::_Callable_obj<_Ty,_Indirect>::_ApplyX<_Ret,_Arg&>(_Arg0)' being compiled
1> with
1> [
1> _Ret=_Rx,
1> _Ty=Foo,
1> _Indirect=false,
1> _Arg=std::tr1::reference_wrapper<int>,
1> _Arg0=std::tr1::reference_wrapper<int> &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxbind0(31) : see reference to function template instantiation '_Ret std::tr1::_Bind1<_Callable,_Arg0>::_ApplyX<_Rx,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&,std::tr1::_Nil&>(_Barg0,_Barg1,_Barg2,_Barg3,_Barg4,_Barg5,_Barg6,_Barg7,_Barg8,_Barg9)' being compiled
1> with
1> [
1> _Ret=_Rx,
1> _Callable=std::tr1::_Callable_obj<Foo,false>,
1> _Arg0=std::tr1::reference_wrapper<int>,
1> _Barg0=std::tr1::_Nil &,
1> _Barg1=std::tr1::_Nil &,
1> _Barg2=std::tr1::_Nil &,
1> _Barg3=std::tr1::_Nil &,
1> _Barg4=std::tr1::_Nil &,
1> _Barg5=std::tr1::_Nil &,
1> _Barg6=std::tr1::_Nil &,
1> _Barg7=std::tr1::_Nil &,
1> _Barg8=std::tr1::_Nil &,
1> _Barg9=std::tr1::_Nil &
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxbind0(27) : while compiling class template member function 'void std::tr1::_Bind_base<_Ret,_BindN>::operator ()(void)'
1> with
1> [
1> _Ret=std::tr1::_Notforced,
1> _BindN=std::tr1::_Bind1<std::tr1::_Callable_obj<Foo,false>,std::tr1::reference_wrapper<int>>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\functional(408) : see reference to class template instantiation 'std::tr1::_Bind_base<_Ret,_BindN>' being compiled
1> with
1> [
1> _Ret=std::tr1::_Notforced,
1> _BindN=std::tr1::_Bind1<std::tr1::_Callable_obj<Foo,false>,std::tr1::reference_wrapper<int>>
1> ]
1> test.cpp(21) : see reference to class template instantiation 'std::tr1::_Bind_fty<_Fty,_Ret,_BindN>' being compiled
1> with
1> [
1> _Fty=Foo,
1> _Ret=std::tr1::_Notforced,
1> _BindN=std::tr1::_Bind1<std::tr1::_Callable_obj<Foo,false>,std::tr1::reference_wrapper<int>>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========