Migrate to capy post-#262 buffer API#270
Merged
Merged
Conversation
cppalliance/capy#262 removes the slice CPO machinery (`capy::prefix`, `capy::sans_prefix`, `capy::remove_prefix`, `capy::remove_suffix`, `capy::keep_prefix`, `capy::slice_of<>`) and the `capy::const_buffer_pair` / `capy::mutable_buffer_pair` aliases. boost::http migrates to the replacements: - `capy::const_buffer_pair` / `capy::mutable_buffer_pair` --> `std::array<capy::const_buffer, 2>` / `std::array<capy::mutable_buffer, 2>`. - `capy::prefix(seq, n)` returning a 2-element buffer pair --> local helper `prefix_pair(seq, n)` in `src/parser.cpp` that constructs the trimmed array directly. Retained for the call sites that consume the result as a std::array (i.e. assigning to a parser member or passing to `filter::process`). - For one parser site where the result is consumed by `capy::buffer_copy`, the migration uses `capy::buffer_slice` directly: `auto chunk = capy::buffer_slice(cb0_.data(), 0, n);` then `buffer_copy(target, chunk.data())`. Demonstrates the by-value buffer_slice's idiomatic use; the slice owns its buffer-sequence copy and works with the prvalue `cb0_.data()`. - `capy::remove_prefix(pair, n)` / `capy::remove_suffix(pair, n)` on 2-element buffer pairs --> local helpers `trim_prefix_pair` / `trim_suffix_pair` in `src/serializer.cpp`. Retained for `out_prepare()`'s in-place std::array trim. - `capy::remove_prefix(buf, n)` on a single buffer --> `buf += n` (member operator already provided by capy). - `capy::sans_prefix(seq, n)` --> `capy::buffer_slice(seq, n)` (returns a Slice exposing the buffer sequence via `.data()`). In iterative consumption loops, advance an existing slice in place via `slice.remove_prefix(n)`. - `filter::process` now takes `boost::span<const capy::mutable_buffer>` and `std::array<capy::const_buffer, 2>` directly, and drives the loop using `capy::buffer_slice` internally. - Test serializer.cpp's `read_some` builds a slice in one expression via `capy::buffer_slice(sr.prepare().value(), 0, 256)` and iterates `.data()`. Since capy's buffer_slice captures its underlying buffer sequence by value, the prvalue `sr.prepare() .value()` is safe — the slice owns its own copy. Coordinated with capy PR cppalliance/capy#262. Merge order: this PR lands before cppalliance#262 (so http remains buildable against capy's \`develop\` during the brief window).
|
An automated preview of the documentation is available at https://270.http.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-05-15 21:13:19 UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cppalliance/capy#262 removes the slice CPO machinery (
capy::prefix,capy::sans_prefix,capy::remove_prefix,capy::remove_suffix,capy::keep_prefix,capy::slice_of<>) and thecapy::const_buffer_pair/capy::mutable_buffer_pairaliases. boost::http migrates to the replacements:capy::const_buffer_pair/capy::mutable_buffer_pair-->std::array<capy::const_buffer, 2>/std::array<capy::mutable_buffer, 2>.capy::prefix(seq, n)returning a 2-element buffer pair --> local helperprefix_pair(seq, n)insrc/parser.cppthat constructs the trimmed array directly. Retained for the call sites that consume the result as a std::array (i.e. assigning to a parser member or passing tofilter::process).For one parser site where the result is consumed by
capy::buffer_copy, the migration usescapy::buffer_slicedirectly:auto chunk = capy::buffer_slice(cb0_.data(), 0, n);thenbuffer_copy(target, chunk.data()). Demonstrates the by-value buffer_slice's idiomatic use; the slice owns its buffer-sequence copy and works with the prvaluecb0_.data().capy::remove_prefix(pair, n)/capy::remove_suffix(pair, n)on 2-element buffer pairs --> local helperstrim_prefix_pair/trim_suffix_pairinsrc/serializer.cpp. Retained forout_prepare()'s in-place std::array trim.capy::remove_prefix(buf, n)on a single buffer -->buf += n(member operator already provided by capy).capy::sans_prefix(seq, n)-->capy::buffer_slice(seq, n)(returns a Slice exposing the buffer sequence via.data()). In iterative consumption loops, advance an existing slice in place viaslice.remove_prefix(n).filter::processnow takesboost::span<const capy::mutable_buffer>andstd::array<capy::const_buffer, 2>directly, and drives the loop usingcapy::buffer_sliceinternally.Test serializer.cpp's
read_somebuilds a slice in one expression viacapy::buffer_slice(sr.prepare().value(), 0, 256)and iterates.data(). Since capy's buffer_slice captures its underlying buffer sequence by value, the prvaluesr.prepare() .value()is safe — the slice owns its own copy.Coordinated with capy PR cppalliance/capy#262. Merge order: this PR lands before #262 (so http remains buildable against capy's `develop` during the brief window).