Skip to content

refactor!: make io_result an alias for std::tuple - #379

Merged
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/io-result-tuple-alias
Aug 17, 2026
Merged

refactor!: make io_result an alias for std::tuple#379
sgerbino merged 1 commit into
cppalliance:developfrom
sgerbino:pr/io-result-tuple-alias

Conversation

@sgerbino

Copy link
Copy Markdown
Collaborator

A distinct result type cannot opt into the standard tuple utilities: std::apply is specified in terms of std::get, which cannot be overloaded for program-defined types, and tuple's operator= only accepts tuple-like types, so std::tie can never rebind from one. Define io_result as std::tuple<error_code, Ts...> instead, making tie, apply, tuple_cat, comparisons, and tuple assignment all work (closes #266). tie in particular gives callers a rebinding style that avoids structured bindings entirely.

Outcome detection for the io-aware when_all/when_any overloads is now structural, matching the channel-splitting rule the sender bridge already uses: any tuple whose first element is error_code participates, regardless of spelling.

The type-level [[nodiscard]] migrates to await_resume on the library's awaitables; task gains a nodiscard overload when T is an outcome, so discarding an awaited error still warns.

Two construction idioms had to change. extract_results built its container with CTAD, which now collapses a single child through tuple's copy deduction guide; the element types are spelled out. And the {{}, n} success shorthand is ambiguous in libstdc++, where the leading {} also matches allocator_arg_t in the allocator-extended constructors; success results now spell std::error_code() explicitly.

Resolves #266.

A distinct result type cannot opt into the standard tuple utilities:
std::apply is specified in terms of std::get, which cannot be
overloaded for program-defined types, and tuple's operator= only
accepts tuple-like types, so std::tie can never rebind from one.
Define io_result as std::tuple<error_code, Ts...> instead, making
tie, apply, tuple_cat, comparisons, and tuple assignment all work
(closes cppalliance#266). tie in particular gives callers a rebinding style
that avoids structured bindings entirely.

Outcome detection for the io-aware when_all/when_any overloads is
now structural, matching the channel-splitting rule the sender
bridge already uses: any tuple whose first element is error_code
participates, regardless of spelling.

The type-level [[nodiscard]] migrates to await_resume on the
library's awaitables; task<T> gains a nodiscard overload when T is
an outcome, so discarding an awaited error still warns.

Two construction idioms had to change. extract_results built its
container with CTAD, which now collapses a single child through
tuple's copy deduction guide; the element types are spelled out.
And the {{}, n} success shorthand is ambiguous in libstdc++,
where the leading {} also matches allocator_arg_t in the
allocator-extended constructors; success results now spell
std::error_code() explicitly.
@cppalliance-bot

Copy link
Copy Markdown

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

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

2026-08-17 18:57:53 UTC

@cppalliance-bot

Copy link
Copy Markdown

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

Build time: 2026-08-17 19:12:30 UTC

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.09%. Comparing base (de7c948) to head (836f2c5).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #379   +/-   ##
========================================
  Coverage    98.09%   98.09%           
========================================
  Files          132      130    -2     
  Lines         6288     6291    +3     
========================================
+ Hits          6168     6171    +3     
  Misses         120      120           
Flag Coverage Δ
linux 98.08% <ø> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...nclude/boost/capy/detail/io_result_combinators.hpp 100.00% <100.00%> (ø)
include/boost/capy/ex/async_event.hpp 100.00% <100.00%> (ø)
include/boost/capy/ex/async_mutex.hpp 100.00% <100.00%> (ø)
include/boost/capy/ex/async_waker.hpp 92.95% <100.00%> (ø)
include/boost/capy/ex/immediate.hpp 100.00% <100.00%> (ø)
include/boost/capy/io/any_read_stream.hpp 100.00% <ø> (ø)
include/boost/capy/io/any_write_stream.hpp 100.00% <100.00%> (ø)
include/boost/capy/io/write_now.hpp 100.00% <100.00%> (ø)
include/boost/capy/read.hpp 100.00% <ø> (ø)
include/boost/capy/read_at_least.hpp 100.00% <ø> (ø)
... and 8 more

... and 6 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 de7c948...836f2c5. Read the comment docs.

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

@sgerbino
sgerbino merged commit aed1c30 into cppalliance:develop Aug 17, 2026
39 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

io_result is annoying

2 participants