Can not convert boost :: asio :: netdb :: errors to std :: error_code


I'm trying to compile this code (taken from the cpp-netlib documentation):

#include <boost/network/protocol/http/client.hpp>
#include <iostream>

int main(int argc, char *argv[]) {
    using namespace boost::network;

    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " [url]" << std::endl;
        return 1;

    http::client client;
    http::client::request request(argv[1]);
    request << header("Connection", "close");
    http::client::response response = client.get(request);
    std::cout << body(response) << std::endl;

    return 0;

However, it fails with this error:

Error   C2446   ':': no conversion from 'boost::asio::error::netdb_errors' to 'const std::error_code'

I'm using VS2015, cpp-netlib 0.12.0 (final) and Boost 1.55.0, and I have no idea what could cause this. Is there a way to fix it? I've been scratching my head trying to get this library to work for a few days, but it seems a new error always has to come up unfortunately.

In boost::asio, you're expected to use boost::system::error_code any time you intend to use error codes in your callbacks/invocations, not std::error_code.

I don't know what netlib is doing in the background, but this could be evidence of either a mistake in the reference code, or simply an older version of the code using the wrong symbols.