Skip to content

fix(buffers): make_buffer returns mutable_buffer for by-value mutable…#315

Merged
mvandeberg merged 1 commit into
cppalliance:developfrom
mvandeberg:pr/147-make-buffer-overloads
Jun 15, 2026
Merged

fix(buffers): make_buffer returns mutable_buffer for by-value mutable…#315
mvandeberg merged 1 commit into
cppalliance:developfrom
mvandeberg:pr/147-make-buffer-overloads

Conversation

@mvandeberg

Copy link
Copy Markdown
Contributor

… ranges

The generic mutable overload took an lvalue reference make_buffer(T&), so a boost::span<char> passed as a temporary could not bind to it and fell through to the const overload, returning a const_buffer (#147). std::span<char> only escaped this via a dedicated by-value overload.

Change the generic mutable overloads to a forwarding reference make_buffer(T&&) so by-value mutable contiguous ranges bind there and return mutable_buffer. Remove the now-redundant explicit C-array, std::array, std::vector, std::basic_string, and std::span overloads, which the concept-based generic overloads fully subsume; prune the includes they required.

Behavior is preserved for all non-empty inputs; for empty array/ const-string/span the returned (size-0) buffer's data pointer is now normalized to nullptr, matching vector/string.

Add a prvalue std::span regression test plus a boost::span test guarded by __has_include so Capy still builds and passes without Boost present.

Closes #147

@cppalliance-bot

cppalliance-bot commented Jun 15, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://315.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-06-15 22:47:06 UTC

@cppalliance-bot

cppalliance-bot commented Jun 15, 2026

Copy link
Copy Markdown

GCOVR code coverage report https://315.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://315.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://315.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-06-15 23:00:45 UTC

@mvandeberg mvandeberg force-pushed the pr/147-make-buffer-overloads branch from 7082c0d to 8210d9f Compare June 15, 2026 21:25
… ranges

The generic mutable overload took an lvalue reference `make_buffer(T&)`,
so a `boost::span<char>` passed as a temporary could not bind to it and
fell through to the const overload, returning a `const_buffer` (cppalliance#147).
`std::span<char>` only escaped this via a dedicated by-value overload.

Change the generic mutable overloads to a forwarding reference
`make_buffer(T&&)` so by-value mutable contiguous ranges bind there and
return `mutable_buffer`. Remove the now-redundant explicit C-array,
std::array, std::vector, std::basic_string, and std::span overloads,
which the concept-based generic overloads fully subsume; prune the
includes they required.

Behavior is preserved for all non-empty inputs; for empty array/
const-string/span the returned (size-0) buffer's data pointer is now
normalized to nullptr, matching vector/string.

Add a prvalue std::span regression test plus a boost::span test guarded
by __has_include so Capy still builds and passes without Boost present.
@mvandeberg mvandeberg force-pushed the pr/147-make-buffer-overloads branch from 8210d9f to 8338803 Compare June 15, 2026 22:41
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.07%. Comparing base (e1e42af) to head (8338803).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #315      +/-   ##
===========================================
- Coverage    98.09%   98.07%   -0.03%     
===========================================
  Files          164      164              
  Lines         8873     8757     -116     
===========================================
- Hits          8704     8588     -116     
  Misses         169      169              
Flag Coverage Δ
linux 98.16% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/boost/capy/buffers/make_buffer.hpp 100.00% <100.00%> (ø)
include/boost/capy/test/buffer_source.hpp 94.28% <ø> (ø)

... and 10 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1e42af...8338803. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mvandeberg mvandeberg merged commit 2f7997c into cppalliance:develop Jun 15, 2026
38 of 39 checks passed
@mvandeberg mvandeberg deleted the pr/147-make-buffer-overloads branch June 15, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make_buffer(boost::span<char>) returns a const_buffer

2 participants