c++ - Boost bind with asio::placeholders::error -
why doesn't work?
--- boost_bind.cc ---
#include <asio.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> void func1 (const int& i) { } void func2 (const ::asio::error_code& e) { } int main () { ::boost::function<void()> f1 = ::boost::bind (&func1, 1); // doesn't work! ::boost::function<void()> f2 = ::boost::bind (&func2, ::asio::placeholders::error); return 0; }
this error:
while_true@localhost:~> g++ -lpthread boost_bind.cc -o boost_bind in file included boost_bind.cc:2: /usr/include/boost/bind.hpp: in member function ‘void boost::_bi::list1::operator()(boost::_bi::type, f&, a&, int) [with f = void (*)(const asio::error_code&), = boost::_bi::list0, a1 = boost::arg (*)()]’: /usr/include/boost/bind/bind_template.hpp:20: instantiated ‘typename boost::_bi::result_traits::type boost::_bi::bind_t::operator()() [with r = void, f = void (*)(const asio::error_code&), l = boost::_bi::list1 (*)()>]’ /usr/include/boost/function/function_template.hpp:152: instantiated ‘static void boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::function_buffer&) [with functionobj = boost::_bi::bind_t (*)()> >, r = void]’ /usr/include/boost/function/function_template.hpp:904: instantiated ‘void boost::function0::assign_to(functor) [with functor = boost::_bi::bind_t (*)()> >, r = void]’ /usr/include/boost/function/function_template.hpp:720: instantiated ‘boost::function0::function0(functor, typename boost::enable_if_c::type) [with functor = boost::_bi::bind_t (*)()> >, r = void]’ /usr/include/boost/function/function_template.hpp:1040: instantiated ‘boost::function::function(functor, typename boost::enable_if_c::type) [with functor = boost::_bi::bind_t (*)()> >, r = void]’ boost_bind.cc:14: instantiated here /usr/include/boost/bind.hpp:232: error: no match ‘operator[]’ in ‘a[boost::_bi::storage1 (*)()>::a1_ [with int = 1]]’ while_true@localhost:~>
i think should write boost::asio::placeholders::error
instead of ::asio::placeholders::error
. also, don't understand purpose of ::
have in front of boost
namespace.
Comments
Post a Comment