Rewording from a previous post:
Are there any issues with binding a boost:ref to a free templated
function? On gcc32 this generates an error:
class Test { };
template <class T> void foo(T arg_) { }
int main(int)
{
Test t;
boost::reference_wrapper<Test> tr(t);
boost::function fun1 =
boost::bind(&::foo, tr); // line
41
}
- Alex
________________________________
From: Barchenkov, Alexei (IT)
Sent: Friday, March 23, 2007 12:55 PM
To: boost-users@lists.boost.org
Subject: question about binding a boost::reference_wrapper argument
inside a templated function
I am getting an error when compiling the following code on gcc32. Could
someone please point out what is the problem? Thank you.
class Test { };
template <class T>
void foo(T arg_) { }
template <class T>
void fooRef(const T& arg_){ }
int main(int)
{
Test t;
boost::reference_wrapper<Test> tr(t);
boost::function fun1 =
boost::bind(&::foo, tr); // line
41
boost::function fun2 =
boost::bind(&::fooRef, tr); // line 42
}
....
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/bind.hpp: In member
function `void
boost::_bi::list1<A1>::operator()(boost::_bi::type<void>, F&,
A&, int) [with F = void (*)(boost::reference_wrapper<Test>), A =
boost::_bi::list0, A1 = boost::reference_wrapper<Test>]':
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/bind/bind_template.h
pp:20: instantiated from `boost::_bi::result_traits::type
boost::_bi::bind_t::operator()() [with R = void, F = void
(*)(boost::reference_wrapper<Test>), L =
boost::_bi::list1]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:136: instantiated from `static void
boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::_bi::bind_t >, R = void]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:479: instantiated from `void boost::function0::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:430: instantiated from `void boost::function0::assign_to(Functor) [with Functor = boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:294: instantiated from `boost::function0::function0(Functor,
boost::enable_if_c::value, int>::type) [with Functor = boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:638: instantiated from `boost::function::function(Functor,
boost::enable_if_c::value, int>::type) [with Functor = boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
test10.C:41: instantiated from here
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/bind.hpp:229:
conversion
from `Test' to non-scalar type `boost::reference_wrapper<Test>'
requested
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/bind.hpp: In member
function `void
boost::_bi::list1<A1>::operator()(boost::_bi::type<void>, F&,
A&, int) [with F = void (*)(const boost::reference_wrapper<Test>&), A
=
boost::_bi::list0, A1 = boost::reference_wrapper<Test>]':
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/bind/bind_template.h
pp:20: instantiated from `boost::_bi::result_traits::type
boost::_bi::bind_t::operator()() [with R = void, F = void
(*)(const boost::reference_wrapper<Test>&), L =
boost::_bi::list1]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:136: instantiated from `static void
boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::_bi::bind_t >, R = void]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:479: instantiated from `void boost::function0::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:430: instantiated from `void boost::function0::assign_to(Functor) [with Functor = boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:294: instantiated from `boost::function0::function0(Functor,
boost::enable_if_c::value, int>::type) [with Functor = boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:638: instantiated from `boost::function::function(Functor,
boost::enable_if_c::value, int>::type) [with Functor = boost::_bi::bind_t >, R = void,
Allocator = std::allocator<void>]'
test10.C:42: instantiated from here
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/bind.hpp:229: could
not
convert `(+a)->boost::_bi::list0::operator[](const
boost::reference_wrapper<T>&) const [with T = Test](this)' to `const
boost::reference_wrapper<Test>&'
--------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.