// // line_reader.hpp // ~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff 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 LINE_READER_HPP #define LINE_READER_HPP #include #include #include #include class line_reader { private: virtual void async_read_line_impl(std::string prompt, asio::any_completion_handler handler) = 0; struct initiate_read_line { template void operator()(Handler handler, line_reader* self, std::string prompt) { self->async_read_line_impl(std::move(prompt), std::move(handler)); } }; public: virtual ~line_reader() {} template auto async_read_line(std::string prompt, CompletionToken&& token) -> decltype( asio::async_initiate( initiate_read_line(), token, this, prompt)) { return asio::async_initiate( initiate_read_line(), token, this, prompt); } }; #endif // LINE_READER_HPP