diff --git a/src/ripple/basics/Expected.h b/src/ripple/basics/Expected.h index 09d2bdc5042..8dc368eefd7 100644 --- a/src/ripple/basics/Expected.h +++ b/src/ripple/basics/Expected.h @@ -21,7 +21,10 @@ #define RIPPLE_BASICS_EXPECTED_H_INCLUDED #include + #include + +#include #include #include @@ -132,17 +135,16 @@ class [[nodiscard]] Expected using Base = boost::outcome_v2::result; public: - template < - typename U, - typename = std::enable_if_t>> - constexpr Expected(U r) : Base(T{std::forward(r)}) + template + requires std::convertible_to constexpr Expected(U && r) + : Base(T{std::forward(r)}) { } - template < - typename U, - typename = std::enable_if_t>> - constexpr Expected(Unexpected e) : Base(E{std::forward(e.value())}) + template + requires std::convertible_to && + (!std::is_reference_v)constexpr Expected(Unexpected e) + : Base(E{std::move(e.value())}) { } @@ -215,10 +217,10 @@ class [[nodiscard]] Expected { } - template < - typename U, - typename = std::enable_if_t>> - constexpr Expected(Unexpected e) : Base(E{std::forward(e.value())}) + template + requires std::convertible_to && + (!std::is_reference_v)constexpr Expected(Unexpected e) + : Base(E{std::move(e.value())}) { }