|
Boost : |
Subject: [boost] [config] BOOST_NO_CXX11_HDR_FUNCTIONAL and VC++10
From: Edward Diener (eldiener_at_[hidden])
Date: 2014-08-30 21:16:56
While BOOST_NO_CXX11_HDR_FUNCTIONAL is not defined for VC++10 my tests
show that std::ref in VC++10 is broken in a very simple case. Here is
the code for that case:
// test_vc10_refwrapper.cpp
#include <functional>
class p_functor_class_char
{
public:
p_functor_class_char() : data('A') {}
char operator()() { return data; }
private:
char data;
};
void main()
{
p_functor_class_char pfcc;
std::function<char ()> sf(std::ref(pfcc));
}
which for VC++10 gives:
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallobj(13) : error C2440: 'return' : cannot convert from 'void' to 'char'
> Expressions of type void cannot be converted to other types
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxfunction(65) : see reference to function template instantiation '_Ret std::tr1::_Callable_obj<_Ty>::_ApplyX<_Rx>(void)' being compiled
> with
> [
> _Ret=char,
> _Ty=std::tr1::reference_wrapper<p_functor_class_char>,
> _Rx=char
> ]
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxfunction(64) : while compiling class template member function 'char std::tr1::_Impl_no_alloc0<_Callable,_Rx>::_Do_call(void)'
> with
> [
> _Callable=_MyWrapper,
> _Rx=char
> ]
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxfunction(386) : see reference to class template instantiation 'std::tr1::_Impl_no_alloc0<_Callable,_Rx>' being compiled
> with
> [
> _Callable=_MyWrapper,
> _Rx=char
> ]
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxfunction(369) : see reference to function template instantiation 'void std::tr1::_Function_impl0<_Ret>::_Reset0o<_Myimpl,_Fty,std::allocator<_Ty>>(_Fty,_Alloc)' being compiled
> with
> [
> _Ret=char,
> _Fty=std::tr1::reference_wrapper<p_functor_class_char>,
> _Ty=std::tr1::_Function_impl0<char>,
> _Alloc=std::allocator<std::tr1::_Function_impl0<char>>
> ]
> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\functional(126) : see reference to function template instantiation 'void std::tr1::_Function_impl0<_Ret>::_Reset<std::tr1::reference_wrapper<_Ty>>(_Fty)' being compiled
> with
> [
> _Ret=char,
> _Ty=p_functor_class_char,
> _Fty=std::tr1::reference_wrapper<p_functor_class_char>
> ]
> test_vc10_refwrapper.cpp(15) : see reference to function template instantiation 'std::tr1::function<_Fty>::function<p_functor_class_char>(std::tr1::reference_wrapper<_Ty>)' being compiled
> with
> [
> _Fty=char (void),
> _Ty=p_functor_class_char
> ]
With VC++11 and VC++12 this has been fixed. Using boost::function and
boost::ref there are no problems in VC++10.
I realize that this might not really be an issue in Boost but I was
still wondering if this is a known problem with any Boost developers. I
ran into it during tests, where I was letting
BOOST_NO_CXX11_HDR_FUNCTIONAL determine whether to use std or boost
versions of the functionality in the C++11 <functional> header.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk