Skip to content

Commit

Permalink
Replace std::bind uses with boost::compat::bind_front
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtum committed Mar 31, 2024
1 parent ab58fd8 commit 99ebdf6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function(boost_http_io_setup_properties target)
PUBLIC
Boost::asio
Boost::assert
Boost::compat
Boost::config
Boost::http_proto
Boost::system
Expand Down
24 changes: 11 additions & 13 deletions example/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <boost/http_io.hpp>
#include <boost/http_proto.hpp>
#include <boost/url.hpp>
#include <boost/compat/bind_front.hpp>
#include <boost/core/detail/string_view.hpp>
#include <functional>
#include <iostream>
#include <vector>
#include "fixed_array.hpp"
Expand All @@ -24,10 +24,10 @@ namespace server {
namespace io = boost::http_io;
namespace urls = boost::urls;
namespace asio = boost::asio;
namespace compat = boost::compat;
namespace core = boost::core;
namespace system = boost::system;
namespace http_proto = boost::http_proto;
using namespace std::placeholders;
using tcp = boost::asio::ip::tcp;

//-----------------------------------------------
Expand Down Expand Up @@ -270,10 +270,8 @@ handle_request(
res.append(
http_proto::field::content_type, mt);

sr.start(
res,
http_proto::file_body(
std::move(f), size));
sr.start<http_proto::file_body>(
res, std::move(f), size);
return;
}

Expand Down Expand Up @@ -469,7 +467,7 @@ class worker

grp_.on_worker_idle();
grp_.listener().async_accept( sock_,
std::bind(&worker::on_accept, this, _1));
compat::bind_front(&worker::on_accept, this));
}

void
Expand All @@ -496,8 +494,8 @@ class worker
{
pr_.start();

io::async_read_header(sock_, pr_, std::bind(
&worker::on_read_header, this, _1, _2));
io::async_read_header(sock_, pr_, compat::bind_front(
&worker::on_read_header, this));
}

void
Expand All @@ -515,8 +513,8 @@ class worker
return do_accept();
}

io::async_read(sock_, pr_, std::bind(
&worker::on_read_body, this, _1, _2));
io::async_read(sock_, pr_, compat::bind_front(
&worker::on_read_body, this));
}

void
Expand Down Expand Up @@ -558,8 +556,8 @@ class worker
"--------------------------------------------------\n";
#endif

io::async_write(sock_, sr_, std::bind(
&worker::on_write, this, _1, _2));
io::async_write(sock_, sr_, compat::bind_front(
&worker::on_write, this));
}

void
Expand Down

0 comments on commit 99ebdf6

Please sign in to comment.