// { dg-do compile { target c++23 } } // LWG 3877. Incorrect constraints on const-qualified monadic overloads #include struct T1 { }; struct T2 { T2(const T2&) = delete; }; struct T3 { T3(const T3&) = delete; T3(T3&&) = delete; T3(T3&) { } T3(const T3&&) { } }; template concept Has_and_then = requires(Exp&& exp, F f) { std::forward(exp).and_then(f); }; using ExpiT1 = std::expected; static_assert( Has_and_then ); static_assert( Has_and_then ); static_assert( Has_and_then ); static_assert( Has_and_then ); using ExpiT2 = std::expected; static_assert( !Has_and_then ); static_assert( !Has_and_then ); static_assert( !Has_and_then ); static_assert( !Has_and_then ); using ExpiT3 = std::expected; static_assert( Has_and_then ); static_assert( !Has_and_then ); static_assert( Has_and_then ); // uses and_then(F) const && static_assert( Has_and_then ); template concept Has_or_else = requires(Exp&& exp, F f) { std::forward(exp).or_else(f); }; using ExpT1i = std::expected; static_assert( Has_or_else ); static_assert( Has_or_else ); static_assert( Has_or_else ); static_assert( Has_or_else ); using ExpT2i = std::expected; static_assert( !Has_or_else ); static_assert( !Has_or_else ); static_assert( !Has_or_else ); static_assert( !Has_or_else ); using ExpT3i = std::expected; static_assert( Has_or_else ); static_assert( !Has_or_else ); static_assert( Has_or_else ); // uses or_else(F) const && static_assert( Has_or_else ); template concept Has_transform = requires(Exp&& exp, F f) { std::forward(exp).transform(f); }; static_assert( Has_transform ); static_assert( Has_transform ); static_assert( Has_transform ); static_assert( Has_transform ); static_assert( !Has_transform ); static_assert( !Has_transform ); static_assert( !Has_transform ); static_assert( !Has_transform ); static_assert( Has_transform ); static_assert( !Has_transform ); static_assert( Has_transform ); // uses transform(F) const && static_assert( Has_transform ); template concept Has_transform_error = requires(Exp&& exp, F f) { std::forward(exp).transform_error(f); }; static_assert( Has_transform_error ); static_assert( Has_transform_error ); static_assert( Has_transform_error ); static_assert( Has_transform_error ); static_assert( !Has_transform_error ); static_assert( !Has_transform_error ); static_assert( !Has_transform_error ); static_assert( !Has_transform_error ); static_assert( Has_transform_error ); static_assert( !Has_transform_error ); static_assert( Has_transform_error ); // uses transform_error(F) const && static_assert( Has_transform_error ); // std::expected using ExpvT1 = std::expected; static_assert( Has_and_then ); static_assert( Has_and_then ); static_assert( Has_and_then ); static_assert( Has_and_then ); using ExpvT2 = std::expected; static_assert( !Has_and_then ); static_assert( !Has_and_then ); static_assert( !Has_and_then ); static_assert( !Has_and_then ); using ExpvT3 = std::expected; static_assert( Has_and_then ); static_assert( !Has_and_then ); static_assert( Has_and_then ); // uses and_then(F) const && static_assert( Has_and_then ); using Expvi = std::expected; static_assert( Has_or_else ); static_assert( Has_or_else ); static_assert( Has_or_else ); static_assert( Has_or_else ); static_assert( Has_transform ); static_assert( Has_transform ); static_assert( Has_transform ); static_assert( Has_transform ); static_assert( !Has_transform ); static_assert( !Has_transform ); static_assert( !Has_transform ); static_assert( !Has_transform ); static_assert( Has_transform ); static_assert( !Has_transform ); static_assert( Has_transform ); // uses transform(F) const && static_assert( Has_transform ); static_assert( Has_transform_error ); static_assert( Has_transform_error ); static_assert( Has_transform_error ); static_assert( Has_transform_error );