Skip to content

Fixed default template parameters for value_or/operator= in pfn::expected#236

Merged
Bronek merged 4 commits into
mainfrom
bronek/default_value_or_template_params
Jun 15, 2026
Merged

Fixed default template parameters for value_or/operator= in pfn::expected#236
Bronek merged 4 commits into
mainfrom
bronek/default_value_or_template_params

Conversation

@Bronek

@Bronek Bronek commented Jun 15, 2026

Copy link
Copy Markdown
Member

No description provided.

Bronek added 2 commits June 15, 2026 17:50
The [expected.object.general] synopsis defaults these to remove_cv_t<T>:
value_or had no default, operator=(U&&) defaulted to T. The test guards
both value_or overloads via a non-deducible {} argument; operator='s
default is unobservable (T vs remove_cv_t<T> differ only for cv T, where
the assignment is constrained away).

Assisted-by: Claude:claude-opus-4-8
@augmentcode

augmentcode Bot commented Jun 15, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Makes pfn::expected accept braced-init defaults (e.g. {}) for value_or and value-assignment, matching the standard library’s late C++23 defect resolution.

Changes:

  • Adds a default template argument (std::remove_cv_t<T>) to both detail::_storage::value_or overloads so value_or({}) is well-formed.
  • Updates expected::operator=(U&&)’s default from T to std::remove_cv_t<T> for conformance.
  • Adds regression tests for e = {} and value_or({}) (with stdlib-version gating in validation mode).

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tests/pfn/expected.cpp
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Bronek added 2 commits June 15, 2026 20:52
The validation TU recompiles expected.cpp against std::expected. The
value_or({}) probe needs the synopsis `= remove_cv_t<T>` default, which
libstdc++ added in GCC 15 and libc++ in LLVM 22 -- gate it on those.

Also cover operator=(U&&)'s default: an immovable E drops the copy/move
assignment overloads from expected, so e={} is well-formed only via the
value assignment's defaulted U. std has always had this default, so it
needs no gate.

Assisted-by: Claude:claude-opus-4-8
Assisted-by: Claude:claude-opus-4-8
@sonarqubecloud

Copy link
Copy Markdown

@Bronek

Bronek commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@Bronek Bronek merged commit 9e8a6de into main Jun 15, 2026
108 checks passed
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.

1 participant