Boost logo

Boost :

From: Gustavo Guerra (gustavobt_at_[hidden])
Date: 2002-10-29 21:05:41


Hi
I get a lot of errors when I try to bind a free function with an auto_ptr
argument.

Simple illustrative code, tested in gcc 3.2 (cygwin) with both 1.29 and
current CVS:

void foo(auto_ptr<int> i_aptr);

int f()
{
  auto_ptr<int> i_aptr(new int(0));
  function0<void> f = bind(&foo, i_aptr);
}

What am I doing wrong? It seems to be some problem with const correctness.

TIA
Gustavo Guerra

PS: The erros I get are:

main.cpp:33: no matching function for call to `boost::_bi::bind_t<void, void
   (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >::bind_t(
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >)'
P:/CVS/boost/boost/bind.hpp:911: candidates are: boost::_bi::bind_t<void,
void
   (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >
>::bind_t(boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >&)
main.cpp:33: initializing argument 1 of `boost::function0<R,
   Allocator>::function0(Functor) [with Functor = boost::_bi::bind_t<void,
void
   (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
   Allocator = std::allocator<boost::function_base>]'
P:/CVS/boost/boost/bind/bind_cc.hpp: In function `boost::_bi::bind_t<R, R
   (*)(B1), boost::_bi::list_av_1<A1>::type> boost::bind(R (*)(B1), A1)
[with R
   = void, B1 = std::auto_ptr<int>, A1 = std::auto_ptr<int>]':
main.cpp:33: instantiated from here
P:/CVS/boost/boost/bind/bind_cc.hpp:31: no matching function for call to `
   boost::_bi::value<std::auto_ptr<int> >::value(
   boost::_bi::value<std::auto_ptr<int> >)'
P:/CVS/boost/boost/bind.hpp:77: candidates are:
   boost::_bi::value<std::auto_ptr<int>
>::value(boost::_bi::value<std::auto_ptr<int> >&)
P:/CVS/boost/boost/bind.hpp:80:
   boost::_bi::value<T>::value(const T&) [with T = std::auto_ptr<int>]
P:/CVS/boost/boost/bind/bind_cc.hpp:31: initializing argument 1 of `
   boost::_bi::list1<A1>::list1(A1) [with A1 =
   boost::_bi::value<std::auto_ptr<int> >]' from result of `
   boost::_bi::value<T>::value(const T&) [with T = std::auto_ptr<int>]'
main.cpp:33: instantiated from here
P:/CVS/boost/boost/bind/bind_cc.hpp:31: no matching function for call to `
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >::bind_t(
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >)'
P:/CVS/boost/boost/bind.hpp:911: candidates are: boost::_bi::bind_t<void,
void
   (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >
>::bind_t(boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >&)
P:/CVS/boost/boost/bind.hpp: In constructor
`boost::_bi::value<T>::value(const
   T&) [with T = std::auto_ptr<int>]':
P:/CVS/boost/boost/bind/bind_cc.hpp:31: instantiated from
`boost::_bi::bind_t<R, R (*)(B1), boost::_bi::list_av_1<A1>::type>
boost::bind(R (*)(B1), A1) [with R = void, B1 = std::auto_ptr<int>, A1 =
std::auto_ptr<int>]'
main.cpp:33: instantiated from here
P:/CVS/boost/boost/bind.hpp:80: passing `const std::auto_ptr<int>' as `this'
   argument of `std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() [with
   _Tp1 = int, _Tp = int]' discards qualifiers
P:/CVS/boost/boost/bind.hpp: In constructor `boost::_bi::bind_t<R, F,
   L>::bind_t(F, const L&) [with R = void, F = void (*)(std::auto_ptr<int>),
L
   = boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >]':
P:/CVS/boost/boost/bind/bind_cc.hpp:31: instantiated from
`boost::_bi::bind_t<R, R (*)(B1), boost::_bi::list_av_1<A1>::type>
boost::bind(R (*)(B1), A1) [with R = void, B1 = std::auto_ptr<int>, A1 =
std::auto_ptr<int>]'
main.cpp:33: instantiated from here
P:/CVS/boost/boost/bind.hpp:914: no matching function for call to `
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >::list1(const
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >&)'
P:/CVS/boost/boost/function/function_template.hpp:278: candidates are:
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> >
>::list1(boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >&)
P:/CVS/boost/boost/bind.hpp:168:
   boost::_bi::list1<A1>::list1(A1) [with A1 =
   boost::_bi::value<std::auto_ptr<int> >]
/usr/include/c++/3.2/bits/stl_alloc.h: In member function `void
   std::allocator<_Alloc>::construct(_Tp*, const _Tp&) [with _Tp =
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >]':
P:/CVS/boost/boost/function/function_template.hpp:443: instantiated from
`void boost::function0<R, Allocator>::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
Allocator = std::allocator<boost::function_base>]'
P:/CVS/boost/boost/function/function_template.hpp:385: instantiated from
`void boost::function0<R, Allocator>::assign_to(Functor) [with Functor =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
Allocator = std::allocator<boost::function_base>]'
P:/CVS/boost/boost/function/function_template.hpp:278: instantiated from
`boost::function0<R, Allocator>::function0(Functor) [with Functor =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
Allocator = std::allocator<boost::function_base>]'
main.cpp:33: instantiated from here
/usr/include/c++/3.2/bits/stl_alloc.h:652: no matching function for call to
`
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >
>::bind_t(const
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >&)'
P:/CVS/boost/boost/function/function_template.hpp:278: candidates are:
   boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >
>::bind_t(boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
   boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >&)
P:/CVS/boost/boost/bind.hpp:914: boost::_bi::bind_t<R, F,
   L>::bind_t(F, const L&) [with R = void, F = void (*)(std::auto_ptr<int>),
L
   = boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >]
P:/CVS/boost/boost/bind.hpp: In member function `R
   boost::_bi::list1<A1>::operator()(boost::_bi::type<R>, F, A&) const [with
R
   = void, F = void (*)(std::auto_ptr<int>), A = boost::_bi::list0, A1 =
   boost::_bi::value<std::auto_ptr<int> >]':
P:/CVS/boost/boost/bind/bind_template.hpp:21: instantiated from
`boost::_bi::result_traits<R, F>::type boost::_bi::bind_t<R, F,
L>::operator()() [with R = void, F = void (*)(std::auto_ptr<int>), L =
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > >]'
P:/CVS/boost/boost/function/function_template.hpp:135: instantiated from
`static boost::detail::function::unusable
boost::detail::function::void_function_obj_invoker0<FunctionObj,
R>::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void]'
P:/CVS/boost/boost/function/function_template.hpp:434: instantiated from
`void boost::function0<R, Allocator>::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
Allocator = std::allocator<boost::function_base>]'
P:/CVS/boost/boost/function/function_template.hpp:385: instantiated from
`void boost::function0<R, Allocator>::assign_to(Functor) [with Functor =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
Allocator = std::allocator<boost::function_base>]'
P:/CVS/boost/boost/function/function_template.hpp:278: instantiated from
`boost::function0<R, Allocator>::function0(Functor) [with Functor =
boost::_bi::bind_t<void, void (*)(std::auto_ptr<int>),
boost::_bi::list1<boost::_bi::value<std::auto_ptr<int> > > >, R = void,
Allocator = std::allocator<boost::function_base>]'
main.cpp:33: instantiated from here
P:/CVS/boost/boost/bind.hpp:186: passing `const std::auto_ptr<int>' as
`this'
   argument of `std::auto_ptr<_Tp>::operator std::auto_ptr_ref<_Tp1>() [with
   _Tp1 = int, _Tp = int]' discards qualifiers
make: *** [main.o] Error 1


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk