From 7d8e40537a6fe143b105c05198ab3ca9066b4313 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 10 May 2017 13:08:11 -0700 Subject: [PATCH] Remove placeholders (API Change) --- CHANGELOG.md | 1 + examples/http_async_server.hpp | 14 ++++----- examples/http_sync_server.hpp | 5 ++-- examples/websocket_async_echo_server.hpp | 5 ++-- examples/websocket_sync_echo_server.hpp | 5 ++-- include/beast/core.hpp | 1 - include/beast/core/placeholders.hpp | 30 ------------------- test/Jamfile | 1 - test/core/CMakeLists.txt | 1 - test/core/placeholders.cpp | 9 ------ .../ssl/websocket_async_ssl_echo_server.hpp | 5 ++-- .../websocket/websocket_async_echo_server.hpp | 5 ++-- test/websocket/websocket_sync_echo_server.hpp | 5 ++-- 13 files changed, 20 insertions(+), 67 deletions(-) delete mode 100644 include/beast/core/placeholders.hpp delete mode 100644 test/core/placeholders.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bbb923b..488e20f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Version 41 API Changes * Return http::error::end_of_stream on HTTP read eof +* Remove placeholders -------------------------------------------------------------------------------- diff --git a/examples/http_async_server.hpp b/examples/http_async_server.hpp index 5be89d0f..5506603e 100644 --- a/examples/http_async_server.hpp +++ b/examples/http_async_server.hpp @@ -14,11 +14,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -58,7 +58,7 @@ public: boost::asio::socket_base::max_connections); acceptor_.async_accept(sock_, std::bind(&http_async_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); thread_.reserve(threads); for(std::size_t i = 0; i < threads; ++i) thread_.emplace_back( @@ -218,7 +218,7 @@ private: { async_read(sock_, sb_, req_, strand_.wrap( std::bind(&peer::on_read, shared_from_this(), - asio::placeholders::error))); + std::placeholders::_1))); } void on_read(error_code const& ec) @@ -241,7 +241,7 @@ private: prepare(res); async_write(sock_, std::move(res), std::bind(&peer::on_write, shared_from_this(), - asio::placeholders::error)); + std::placeholders::_1)); return; } try @@ -256,7 +256,7 @@ private: prepare(res); async_write(sock_, std::move(res), std::bind(&peer::on_write, shared_from_this(), - asio::placeholders::error)); + std::placeholders::_1)); } catch(std::exception const& e) { @@ -271,7 +271,7 @@ private: prepare(res); async_write(sock_, std::move(res), std::bind(&peer::on_write, shared_from_this(), - asio::placeholders::error)); + std::placeholders::_1)); } } @@ -312,7 +312,7 @@ private: socket_type sock(std::move(sock_)); acceptor_.async_accept(sock_, std::bind(&http_async_server::on_accept, this, - asio::placeholders::error)); + std::placeholders::_1)); std::make_shared(std::move(sock), *this)->run(); } }; diff --git a/examples/http_sync_server.hpp b/examples/http_sync_server.hpp index bbc43fad..4b80cb47 100644 --- a/examples/http_sync_server.hpp +++ b/examples/http_sync_server.hpp @@ -12,7 +12,6 @@ #include "mime_type.hpp" #include -#include #include #include #include @@ -59,7 +58,7 @@ public: boost::asio::socket_base::max_connections); acceptor_.async_accept(sock_, std::bind(&http_sync_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); thread_ = std::thread{[&]{ ios_.run(); }}; } @@ -143,7 +142,7 @@ private: std::thread{lambda{++id_, *this, std::move(sock_)}}.detach(); acceptor_.async_accept(sock_, std::bind(&http_sync_server::on_accept, this, - asio::placeholders::error)); + std::placeholders::_1)); } void diff --git a/examples/websocket_async_echo_server.hpp b/examples/websocket_async_echo_server.hpp index e7fda7c2..49e8472e 100644 --- a/examples/websocket_async_echo_server.hpp +++ b/examples/websocket_async_echo_server.hpp @@ -8,7 +8,6 @@ #ifndef WEBSOCKET_ASYNC_ECHO_SERVER_HPP #define WEBSOCKET_ASYNC_ECHO_SERVER_HPP -#include #include #include #include @@ -202,7 +201,7 @@ public: return fail("listen", ec); acceptor_.async_accept(sock_, ep_, std::bind(&async_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } private: @@ -351,7 +350,7 @@ private: peer{*this, ep_, std::move(sock_)}; acceptor_.async_accept(sock_, ep_, std::bind(&async_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } }; diff --git a/examples/websocket_sync_echo_server.hpp b/examples/websocket_sync_echo_server.hpp index 7ffdc358..deb2706a 100644 --- a/examples/websocket_sync_echo_server.hpp +++ b/examples/websocket_sync_echo_server.hpp @@ -8,7 +8,6 @@ #ifndef WEBSOCKET_SYNC_ECHO_SERVER_HPP #define WEBSOCKET_SYNC_ECHO_SERVER_HPP -#include #include #include #include @@ -191,7 +190,7 @@ public: return fail("listen", ec); acceptor_.async_accept(sock_, ep_, std::bind(&sync_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); thread_ = std::thread{[&]{ ios_.run(); }}; } @@ -259,7 +258,7 @@ private: std::thread{lambda{*this, ep_, std::move(sock_)}}.detach(); acceptor_.async_accept(sock_, ep_, std::bind(&sync_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } void diff --git a/include/beast/core.hpp b/include/beast/core.hpp index 9ceed1d4..c7b308dd 100644 --- a/include/beast/core.hpp +++ b/include/beast/core.hpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/include/beast/core/placeholders.hpp b/include/beast/core/placeholders.hpp deleted file mode 100644 index c1127789..00000000 --- a/include/beast/core/placeholders.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BEAST_PLACEHOLDERS_HPP -#define BEAST_PLACEHOLDERS_HPP - -#include -#include - -namespace beast { -namespace asio { - -namespace placeholders { -// asio placeholders that work with std::bind -namespace { -static auto const error (std::placeholders::_1); -static auto const bytes_transferred (std::placeholders::_2); -static auto const iterator (std::placeholders::_2); -static auto const signal_number (std::placeholders::_2); -} -} // placeholders - -} // asio -} // beast - -#endif diff --git a/test/Jamfile b/test/Jamfile index 5250cd20..5aa8919d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -31,7 +31,6 @@ unit-test core-tests : core/handler_ptr.cpp core/multi_buffer.cpp core/ostream.cpp - core/placeholders.cpp core/prepare_buffer.cpp core/prepare_buffers.cpp core/static_buffer.cpp diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 78a2b769..ab7f7dc4 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -24,7 +24,6 @@ add_executable (core-tests handler_ptr.cpp multi_buffer.cpp ostream.cpp - placeholders.cpp prepare_buffer.cpp prepare_buffers.cpp static_buffer.cpp diff --git a/test/core/placeholders.cpp b/test/core/placeholders.cpp deleted file mode 100644 index 1f4955d5..00000000 --- a/test/core/placeholders.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -// Test that header file is self-contained. -#include diff --git a/test/websocket/ssl/websocket_async_ssl_echo_server.hpp b/test/websocket/ssl/websocket_async_ssl_echo_server.hpp index d4586210..919571ad 100644 --- a/test/websocket/ssl/websocket_async_ssl_echo_server.hpp +++ b/test/websocket/ssl/websocket_async_ssl_echo_server.hpp @@ -8,7 +8,6 @@ #ifndef WEBSOCKET_ASYNC_SSL_ECHO_SERVER_HPP #define WEBSOCKET_ASYNC_SSL_ECHO_SERVER_HPP -#include #include #include #include @@ -141,7 +140,7 @@ public: return fail("listen", ec); acceptor_.async_accept(sock_, ep_, std::bind(&async_ssl_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } private: @@ -299,7 +298,7 @@ private: connection{*this, ep_, std::move(sock_)}.run(); acceptor_.async_accept(sock_, ep_, std::bind(&async_ssl_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } }; diff --git a/test/websocket/websocket_async_echo_server.hpp b/test/websocket/websocket_async_echo_server.hpp index 14342150..19a51449 100644 --- a/test/websocket/websocket_async_echo_server.hpp +++ b/test/websocket/websocket_async_echo_server.hpp @@ -8,7 +8,6 @@ #ifndef BEAST_WEBSOCKET_ASYNC_ECHO_SERVER_HPP #define BEAST_WEBSOCKET_ASYNC_ECHO_SERVER_HPP -#include #include #include #include @@ -202,7 +201,7 @@ public: return fail("listen", ec); acceptor_.async_accept(sock_, ep_, std::bind(&async_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } private: @@ -405,7 +404,7 @@ private: peer{*this, ep_, std::move(sock_)}; acceptor_.async_accept(sock_, ep_, std::bind(&async_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } }; diff --git a/test/websocket/websocket_sync_echo_server.hpp b/test/websocket/websocket_sync_echo_server.hpp index b454ffcb..4350cb00 100644 --- a/test/websocket/websocket_sync_echo_server.hpp +++ b/test/websocket/websocket_sync_echo_server.hpp @@ -8,7 +8,6 @@ #ifndef BEAST_WEBSOCKET_SYNC_ECHO_SERVER_HPP #define BEAST_WEBSOCKET_SYNC_ECHO_SERVER_HPP -#include #include #include #include @@ -191,7 +190,7 @@ public: return fail("listen", ec); acceptor_.async_accept(sock_, ep_, std::bind(&sync_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); thread_ = std::thread{[&]{ ios_.run(); }}; } @@ -259,7 +258,7 @@ private: std::thread{lambda{*this, ep_, std::move(sock_)}}.detach(); acceptor_.async_accept(sock_, ep_, std::bind(&sync_echo_server::on_accept, this, - beast::asio::placeholders::error)); + std::placeholders::_1)); } template