From b2706e48a8104ba9e024db232e9f340fc5fc7bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Sun, 31 Mar 2024 12:36:08 +0300 Subject: [PATCH] const buffer --- boost_boilerplate/CMakeLists.txt | 9 +++++++-- .../src/chapter02_io/output_buffer.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 boost_boilerplate/src/chapter02_io/output_buffer.cpp diff --git a/boost_boilerplate/CMakeLists.txt b/boost_boilerplate/CMakeLists.txt index e851bc0..0759741 100644 --- a/boost_boilerplate/CMakeLists.txt +++ b/boost_boilerplate/CMakeLists.txt @@ -54,7 +54,12 @@ add_executable(connecting_a_socket src/sdk.h) target_link_libraries(connecting_a_socket PRIVATE Threads::Threads) -add_executable(accepting_connections.cpp +add_executable(accepting_connections src/chapter01_the_basics/accepting_connections.cpp src/sdk.h) -target_link_libraries(accepting_connections.cpp PRIVATE Threads::Threads) +target_link_libraries(accepting_connections PRIVATE Threads::Threads) + +add_executable(output_buffer + src/chapter02_io/output_buffer.cpp + src/sdk.h) +target_link_libraries(output_buffer PRIVATE Threads::Threads) diff --git a/boost_boilerplate/src/chapter02_io/output_buffer.cpp b/boost_boilerplate/src/chapter02_io/output_buffer.cpp new file mode 100644 index 0000000..9d19043 --- /dev/null +++ b/boost_boilerplate/src/chapter02_io/output_buffer.cpp @@ -0,0 +1,13 @@ +#include +#include + +using namespace boost; +using namespace std; + +int main() +{ + string buf = "Hello, World!"s; + asio::const_buffers_1 output_buf = asio::buffer(const_cast(buf)); + + return EXIT_SUCCESS; +}