https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109242
Bug ID: 109242 Summary: C++2b std::optional::transform omits required std::remove_cv_t from return optional type Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: pkasting at google dot com Target Milestone: --- The implementation of C++2b's std::optional::transform() on HEAD omits a call to std::remove_cv_t when determining the value type of the returned optional. As a result valid code such as the following example is rejected: https://godbolt.org/z/hG5hnz59e #include <optional> struct S { int i; }; void foo() { std::optional<S>().transform(&S::i); } Per https://en.cppreference.com/w/cpp/utility/optional/transform, the returned type should always be computed via std::remove_cv_t<> on the invoke_result, but per https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/std/optional;hb=HEAD, _Up consistently omits this.