Search code examples
c++c++11boostboost-asiostdbind

Should I be seeing significant differences between std::bind and boost::bind?


I'm exploring the support for C++11 on the g++-4.7 (Ubuntu/Linaro 4.7.3-2ubuntu~12.04, to be specific) and I seem to be finding differences.

In particular, if I comment out #include <boost/bind.hpp> and systematically replace occurrences of boost::bind with std::bind in the Boost ASIO async client example (taken from http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/http/client/async_client.cpp), the program no longer compiles.

Any explanation for this?


Solution

  • #include <functional>
    namespace boost {
        namespace asio {
            namespace stdplaceholders {
                static decltype ( :: std :: placeholders :: _1 ) & error = :: std :: placeholders :: _1;
                static decltype ( :: std :: placeholders :: _2 ) & bytes_transferred = :: std :: placeholders :: _2;
                static decltype ( :: std :: placeholders :: _2 ) & iterator = :: std :: placeholders :: _2;
                static decltype ( :: std :: placeholders :: _2 ) & signal_number = :: std :: placeholders :: _2;
            }
        }
    }
    

    and use boost::asio::stdplaceholders::* instead of boost::asio::placeholders::*