Skip to content

Conversation

@MungoG
Copy link
Contributor

@MungoG MungoG commented Jan 29, 2026

Replace three separate constructors with a single template constructor that accepts any type convertible to std::error_code. The old approach used #ifdef BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED to conditionally compile the boost::system::error_code constructor. This created a fragile include-order dependency: if io_result.hpp was included before boost/system/error_code.hpp, the direct constructor wasn't available, forcing MSVC to apply two implicit conversions which triggers warning C4927.

The new single template constructor handles all cases uniformly by relying on std::error_code's existing constructors and conversion operators. This eliminates the C4927 warning and removes the need to carefully order includes in headers that use io_result with Boost error codes.

Summary by CodeRabbit

  • Refactor
    • Unified and simplified error-result constructor logic to accept a broader range of error-code types via a single implementation, removing redundant overloads and conditional variants.
  • Documentation
    • Updated comments to describe the new constructor behavior and accepted error-code types while preserving existing public behavior and accessors.

✏️ Tip: You can customize this high-level summary in your review settings.

@MungoG MungoG self-assigned this Jan 29, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Consolidates multiple io_result<> constructors into a single templated constructor that accepts any type convertible to std::error_code, removing the explicit std::error_code and Boost-specific constructors and the enum-based overload. Initializes ec from the provided convertible error type.

Changes

Cohort / File(s) Summary
Error Code Constructor Consolidation
include/boost/capy/io_result.hpp
Removed explicit io_result(std::error_code) and Boost-specific/error-enum constructors. Added a single template<class E, typename std::enable_if<std::is_convertible<E, std::error_code>::value, int>::type = 0> BOOST_CAPY_FORCEINLINE io_result(E const& e) noexcept constructor initializing ec from e. Updated comments accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Three doors I hopped through, one by one,
Now a single tunnel gleams in the sun.
A convertible slip, tidy and neat,
io_result hums with one heartbeat. 🥕✨

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing multiple constructors with a templated constructor to eliminate include-order dependency.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@cppalliance-bot
Copy link

cppalliance-bot commented Jan 29, 2026

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

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

2026-01-29 15:03:10 UTC

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@include/boost/capy/io_result.hpp`:
- Around line 64-74: Update the io_result(E const& e) noexcept constructor
docstring to document the template parameter E, the constructor parameter e, the
template constraint (requires E to be convertible to std::error_code /
std::is_convertible<E, std::error_code>::value), any preconditions (e must
represent a valid error_code) and the noexcept guarantee (constructor is
noexcept and will not throw); mention that the constructor accepts
std::error_code, boost::system::error_code, error-code enums or any type
implicitly convertible to std::error_code and that it initializes the member ec.

Replace three separate constructors with a single template constructor that accepts any type convertible to std::error_code. The old approach used #ifdef BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED to conditionally compile the boost::system::error_code constructor. This created a fragile include-order dependency: if io_result.hpp was included before boost/system/error_code.hpp, the direct constructor wasn't available, forcing MSVC to apply two implicit conversions which triggers warning C4927.

The new single template constructor handles all cases uniformly by relying on std::error_code's existing constructors and conversion operators. This eliminates the C4927 warning and removes the need to carefully order includes in headers that use io_result with Boost error codes.
@MungoG MungoG force-pushed the fix-include-order-issue branch from 349688c to 60efdc5 Compare January 29, 2026 14:56
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.

2 participants