Boost logo

Boost Users :

Subject: [Boost-users] [lambda][tr1] Are the native std::tr1::function in Visual Studio and boost::lambda compatible?
From: jesseperla (jesseperla_at_[hidden])
Date: 2009-07-28 21:12:12


I am using Visual Studio 2008 SP1 with the Intel 11.0 compiler and
boost 1.38.

I am compiling with the pre-processor directive: BOOST_HAS_TR1 (though
I am not sure this does what I thought it did does since I see
boost::tuples is used below).

When I use the native tr1 function, I am unable to put a boost::lambda
into it (which worked fine with boost::function), I get an errors.
Any ideas?

Here is the sample code:
        using boost::lambda::_1;
        auto f = _1;
        std::tr1::function<double (double)> f2(f);
        std::cout << f2(2.0) << endl;

Here is the error.
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xxfunction
(73): error: no suitable conversion function from
1> "const
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>,
boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type>>>" to "const void *" exists
1> return (&_Callee._Get());
1> ^
1> detected during:
1> instantiation of "const void
*std::tr1::_Impl1<_Callable, _Rx, _Arg0, _Alloc>::_Get() const [with
_Callable=std::tr1::_Callable_obj<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
false>, _Rx=double, _Arg0=double, _Alloc=std::allocator<int>]" at line
46
1> instantiation of "std::tr1::_Impl1<_Callable, _Rx,
_Arg0, _Alloc>::_Impl1(_Callable::_MyTy &,
_Alloc::rebind<std::tr1::_Impl1<_Callable, _Rx, _Arg0,
_Alloc>>::other) [with
_Callable=std::tr1::_Callable_obj<boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
false>, _Rx=double, _Arg0=double, _Alloc=std::allocator<int>]" at line
165
1> instantiation of "void std::tr1::_Function_impl1<_Ret,
_Arg0>::_Reset(_Fty, _Alloc) [with _Ret=double, _Arg0=double,
_Fty=boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
_Alloc=std::allocator<int>]" at line 970 of "C:\Program Files
\Microsoft Visual Studio 9.0\VC\include\functional"
1> instantiation of "std::tr1::function<_Fty>::function
(_Fx) [with _Fty=double (double),
_Fx=boost::lambda::lambda_functor<boost::lambda::placeholder<1>>]" at
line 41 of "C:\working\libraries\etk\test\meta\test_mathfunctions.cpp"


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net