Boost logo

Boost Users :

From: Barchenkov, Alexei \(IT\) (Alexei.Barchenkov_at_[hidden])
Date: 2007-04-04 16:11:51


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<void()> fun1 =
boost::bind(&::foo<boost::reference_wrapper<Test> >, tr); // line
41
}

- Alex
 
________________________________

From: Barchenkov, Alexei (IT)
Sent: Friday, March 23, 2007 12:55 PM
To: boost-users_at_[hidden]
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<void()> fun1 =
boost::bind(&::foo<boost::reference_wrapper<Test> >, tr); // line
41
  boost::function<void()> fun2 =
boost::bind(&::fooRef<boost::reference_wrapper<Test> >, 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<R, F>::type
boost::_bi::bind_t<R, F, L>::operator()() [with R = void, F = void
(*)(boost::reference_wrapper<Test>), L =
boost::_bi::list1<boost::reference_wrapper<Test> >]'
/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<FunctionObj,
R>::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(boost::reference_wrapper<Test>),
boost::_bi::list1<boost::reference_wrapper<Test> > >, R = void]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:479: instantiated from `void boost::function0<R,
Allocator>::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(boost::reference_wrapper<Test>),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R,
Allocator>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void,
void (*)(boost::reference_wrapper<Test>),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R,
Allocator>::function0(Functor,
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functo
r>::value>::value, int>::type) [with Functor = boost::_bi::bind_t<void,
void (*)(boost::reference_wrapper<Test>),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R ()(),
Allocator>::function(Functor,
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functo
r>::value>::value, int>::type) [with Functor = boost::_bi::bind_t<void,
void (*)(boost::reference_wrapper<Test>),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R, F>::type
boost::_bi::bind_t<R, F, L>::operator()() [with R = void, F = void
(*)(const boost::reference_wrapper<Test>&), L =
boost::_bi::list1<boost::reference_wrapper<Test> >]'
/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<FunctionObj,
R>::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(const
boost::reference_wrapper<Test>&),
boost::_bi::list1<boost::reference_wrapper<Test> > >, R = void]'
/ms/dist/fsf/PROJ/boost/1.33.1/common/include/boost/function/function_te
mplate.hpp:479: instantiated from `void boost::function0<R,
Allocator>::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(const
boost::reference_wrapper<Test>&),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R,
Allocator>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void,
void (*)(const boost::reference_wrapper<Test>&),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R,
Allocator>::function0(Functor,
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functo
r>::value>::value, int>::type) [with Functor = boost::_bi::bind_t<void,
void (*)(const boost::reference_wrapper<Test>&),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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<R ()(),
Allocator>::function(Functor,
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functo
r>::value>::value, int>::type) [with Functor = boost::_bi::bind_t<void,
void (*)(const boost::reference_wrapper<Test>&),
boost::_bi::list1<boost::reference_wrapper<Test> > >, 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.



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