mirror of
https://github.com/boostorg/asio.git
synced 2026-01-27 06:32:08 +00:00
The _buf literal suffix, defined in namespace asio::buffer_literals, may be used to create const_buffer objects from string, binary integer, and hexadecimal integer literals. These buffer literals may be arbitrarily long. For example: using namespace asio::buffer_literals; asio::const_buffer b1 = "hello"_buf; asio::const_buffer b2 = 0xdeadbeef_buf; asio::const_buffer b3 = 0x01234567'89abcdef'01234567'89abcdef_buf; asio::const_buffer b4 = 0b1010101011001100_buf; The memory associated with a buffer literal is valid for the lifetime of the program. This means that the buffer can be safely used with asynchronous operations: async_write(my_socket, "hello"_buf, my_handler);
30 KiB
30 KiB