
When using boost::asio::buffer with a string literal the terminating null character is included in the buffer size, leading to bugs like accidentally sending out a null character. We could fix this by adding something like this to buffer.hpp: /// Create a new non-modifiable buffer that represents the given character array. /** * @returns A const_buffer value equivalent to: * @code const_buffer( * static_cast<const void*>(data), * (N - 1) * sizeof(char)); @endcode */ template <std::size_t N> inline BOOST_ASIO_CONST_BUFFER buffer( const char (&data)[N]) BOOST_ASIO_NOEXCEPT { return BOOST_ASIO_CONST_BUFFER(data, (N - 1) * sizeof(char)); } But this might cause trouble when using a const char array that is not null-terminated, since we then basically drop the last character. Would this be the best approach?