From c33f2f63603ecd39c8e1b7fd1becac0e03e9b4da Mon Sep 17 00:00:00 2001 From: Steve Gerbino Date: Thu, 23 Jul 2026 15:31:09 +0200 Subject: [PATCH] fix(any_write_sink): accept mutable buffer sequences in write ConstBufferSequence admits mutable sequences, but write windowed them through buffer_param, whose span cannot convert to the type-erased write_(span), so calls such as write(make_buffer(some_string)) failed to instantiate. Use const_buffer_param, as write_eof already does. --- include/boost/capy/io/any_write_sink.hpp | 2 +- test/unit/io/any_write_sink.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/boost/capy/io/any_write_sink.hpp b/include/boost/capy/io/any_write_sink.hpp index 2047bc99d..39900c6bd 100644 --- a/include/boost/capy/io/any_write_sink.hpp +++ b/include/boost/capy/io/any_write_sink.hpp @@ -854,7 +854,7 @@ template io_task any_write_sink::write(CB buffers) { - buffer_param bp(buffers); + const_buffer_param bp(buffers); std::size_t total = 0; for(;;) diff --git a/test/unit/io/any_write_sink.cpp b/test/unit/io/any_write_sink.cpp index 1b0f09034..a57cac86f 100644 --- a/test/unit/io/any_write_sink.cpp +++ b/test/unit/io/any_write_sink.cpp @@ -302,6 +302,27 @@ class any_write_sink_test BOOST_TEST(r.success); } + void + testWriteMutableSequence() + { + test::fuse f; + auto r = f.armed([&](test::fuse&) -> task<> { + test::write_sink ws(f); + + any_write_sink aws(&ws); + + std::string body = "hello world"; + auto [ec, n] = co_await aws.write(make_buffer(body)); + if(ec) + co_return; + + BOOST_TEST_EQ(n, 11u); + BOOST_TEST_EQ(ws.data(), "hello world"); + BOOST_TEST(!ws.eof_called()); + }); + BOOST_TEST(r.success); + } + void testWriteMultiple() { @@ -775,6 +796,7 @@ class any_write_sink_test testWriteSomeEmptyBuffer(); testWriteEmptyBuffer(); testWrite(); + testWriteMutableSequence(); testWriteMultiple(); testWriteBufferSequence(); testWriteSingleBuffer();