Skip to content

Remove tag_invoke customization for buffer sequences (#262)#281

Merged
mvandeberg merged 1 commit into
cppalliance:developfrom
mvandeberg:pr/262-buffer-cleanup
May 14, 2026
Merged

Remove tag_invoke customization for buffer sequences (#262)#281
mvandeberg merged 1 commit into
cppalliance:developfrom
mvandeberg:pr/262-buffer-cleanup

Conversation

@mvandeberg
Copy link
Copy Markdown
Contributor

@mvandeberg mvandeberg commented May 14, 2026

Removes the tag_invoke machinery for buffer-sequence operations and the custom types whose only role was to participate in it. Buffer sequences are now plain ranges of const_buffer or mutable_buffer (or single buffer values).

Removed:

  • size_tag, slice_tag, slice_how tag types and their tag_invoke friends on mutable_buffer, const_buffer, and buffer_array.
  • The generic tag_invoke(size_tag, ConstBufferSequence) overload.
  • slice_of<> and the slice CPOs (keep_prefix, remove_prefix, keep_suffix, remove_suffix, prefix, suffix, sans_prefix, sans_suffix) from buffers/slice.hpp. The file is deleted.
  • const_buffer_pair / mutable_buffer_pair aliases and the free tag_invoke(slice_tag, ...) on them. The aliases were just std::array<X, 2>; users now use std::array directly.

Demoted:

  • buffer_array<N, IsConst> moves from boost::capy:: to boost::capy::detail::. The class itself stays — it's the
    scatter/gather adapter used internally by any_* facilities, and is preserved modulo the namespace move and the removed tag_invoke friends. Convenience aliases detail::const_buffer_array<N> / detail::mutable_buffer_array<N> are preserved for brevity.

Reimplemented:

  • buffer_size is now a plain free function template that iterates the range and sums sizes. No more CPO dispatch. Wrapped with a GCC-only -Wmaybe-uninitialized pragma (matching existing precedent in write_now.hpp) to suppress a GCC 13 false positive in iteration over detail::buffer_array's union storage.

Slice lifetime contract (refines #261):

  • The Slice concept documents the lifetime contract explicitly: a Slice is associated, on construction, with an underlying buffer sequence. The slice — and any buffer sequence returned by its data() — is valid only while that underlying sequence remains valid. The buffer sequence returned by data() is independent of the slice object: subsequent operations on the slice (mutation, copy, move, destruction) do not invalidate an already-obtained view.
  • buffer_slice gains a deleted BufferSequence const&& overload to reject rvalue arguments at compile time. Passing a temporary buffer sequence would produce an immediately dangling slice; the deleted overload surfaces this as a compile error instead of runtime UB.

Updated callers:

  • any_* facilities (any_read_source, any_read_stream, any_write_stream, any_write_sink) use detail::buffer_array<N>.
  • circular_dynamic_buffer's const_buffers_type / mutable_buffers_type are std::array<X, 2> directly.
  • Test infrastructure (bufgrind, test_buffers.hpp) rewritten on top of buffer_slice / Slice.
  • Antora pages (why-capy.adoc, 9m.WhyNotCobalt.adoc, 8c.buffer-composition.adoc) updated to drop references to removed types; the buffer-composition example demonstrates std::array<const_buffer, 2> directly.

Closes #262

@cppalliance-bot
Copy link
Copy Markdown

cppalliance-bot commented May 14, 2026

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

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

2026-05-14 20:46:41 UTC

@cppalliance-bot
Copy link
Copy Markdown

cppalliance-bot commented May 14, 2026

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

Build time: 2026-05-14 20:57:31 UTC

@mvandeberg mvandeberg force-pushed the pr/262-buffer-cleanup branch from 13e2899 to d3955d3 Compare May 14, 2026 20:20
Removes the tag_invoke machinery for buffer-sequence operations and
the custom types whose only role was to participate in it. Buffer
sequences are now plain ranges of `const_buffer` or `mutable_buffer`
(or single buffer values).

Removed:
- `size_tag`, `slice_tag`, `slice_how` tag types and their
  `tag_invoke` friends on `mutable_buffer`, `const_buffer`, and
  `buffer_array`.
- The generic `tag_invoke(size_tag, ConstBufferSequence)` overload.
- `slice_of<>` and the slice CPOs (`keep_prefix`, `remove_prefix`,
  `keep_suffix`, `remove_suffix`, `prefix`, `suffix`, `sans_prefix`,
  `sans_suffix`) from `buffers/slice.hpp`. The file is deleted.
- `const_buffer_pair` / `mutable_buffer_pair` aliases and the free
  `tag_invoke(slice_tag, ...)` on them. The aliases were just
  `std::array<X, 2>`; users now use `std::array` directly.

Demoted:
- `buffer_array<N, IsConst>` moves from `boost::capy::` to
  `boost::capy::detail::`. The class itself stays — it's the
  scatter/gather adapter used internally by `any_*` facilities, and
  is preserved modulo the namespace move and the removed tag_invoke
  friends. Convenience aliases `detail::const_buffer_array<N>` /
  `detail::mutable_buffer_array<N>` are preserved for brevity.

Reimplemented:
- `buffer_size` is now a plain free function template that iterates
  the range and sums sizes. No more CPO dispatch. Wrapped with a
  GCC-only `-Wmaybe-uninitialized` pragma (matching existing
  precedent in `write_now.hpp`) to suppress a GCC 13 false positive
  in iteration over `detail::buffer_array`'s union storage.

`Slice` lifetime contract (refines cppalliance#261):
- The `Slice` concept documents the lifetime contract explicitly: a
  Slice is associated, on construction, with an underlying buffer
  sequence. The slice — and any buffer sequence returned by its
  `data()` — is valid only while that underlying sequence remains
  valid. The buffer sequence returned by `data()` is independent
  of the slice object: subsequent operations on the slice (mutation,
  copy, move, destruction) do not invalidate an already-obtained
  view.
- `buffer_slice` gains a deleted `BufferSequence const&&` overload
  to reject rvalue arguments at compile time. Passing a temporary
  buffer sequence would produce an immediately dangling slice; the
  deleted overload surfaces this as a compile error instead of
  runtime UB.

Updated callers:
- `any_*` facilities (`any_read_source`, `any_read_stream`,
  `any_write_stream`, `any_write_sink`) use `detail::buffer_array<N>`.
- `circular_dynamic_buffer`'s `const_buffers_type` /
  `mutable_buffers_type` are `std::array<X, 2>` directly.
- Test infrastructure (`bufgrind`, `test_buffers.hpp`) rewritten on
  top of `buffer_slice` / `Slice`.
- Antora pages (`why-capy.adoc`, `9m.WhyNotCobalt.adoc`,
  `8c.buffer-composition.adoc`) updated to drop references to
  removed types; the buffer-composition example demonstrates
  `std::array<const_buffer, 2>` directly.
@mvandeberg mvandeberg force-pushed the pr/262-buffer-cleanup branch from d3955d3 to 2edf7ac Compare May 14, 2026 20:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.99%. Comparing base (510a468) to head (2edf7ac).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #281      +/-   ##
===========================================
- Coverage    92.46%   91.99%   -0.48%     
===========================================
  Files          170      164       -6     
  Lines         9535     8944     -591     
===========================================
- Hits          8817     8228     -589     
+ Misses         718      716       -2     
Flag Coverage Δ
linux 92.00% <ø> (-0.47%) ⬇️

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

Files with missing lines Coverage Δ
include/boost/capy/buffers.hpp 96.92% <100.00%> (-3.08%) ⬇️
include/boost/capy/buffers/buffer_slice.hpp 100.00% <ø> (ø)
...ude/boost/capy/buffers/circular_dynamic_buffer.hpp 100.00% <ø> (ø)
include/boost/capy/detail/buffer_array.hpp 98.85% <ø> (ø)
include/boost/capy/detail/slice_impl.hpp 99.11% <100.00%> (-0.89%) ⬇️
include/boost/capy/io/any_buffer_source.hpp 86.62% <ø> (ø)
include/boost/capy/io/any_read_source.hpp 91.11% <ø> (ø)
include/boost/capy/io/any_read_stream.hpp 87.36% <100.00%> (ø)
include/boost/capy/io/any_write_sink.hpp 90.56% <ø> (ø)
include/boost/capy/io/any_write_stream.hpp 94.05% <ø> (ø)
... and 1 more

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 510a468...2edf7ac. 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 3a37a17 into cppalliance:develop May 14, 2026
39 checks passed
@mvandeberg mvandeberg deleted the pr/262-buffer-cleanup branch May 14, 2026 21:38
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.

All customization points pertaining to buffer sequences should be removed

2 participants