Skip to content

Commit

Permalink
Rearrange ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
vt4a2h committed Nov 11, 2024
1 parent 7a1b96b commit fcdced6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/include/fl/expected/expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,6 @@ class Expected
requires (std::is_default_constructible_v<Value_>)
= default;

template<class AnotherError>
requires (std::is_constructible_v<const AnotherError&, Error>)
constexpr explicit(!std::is_convertible_v<const AnotherError&, Error>) Expected(const Unexpected<AnotherError> &unexpected)
noexcept (std::is_nothrow_convertible_v<const AnotherError&, Error>)
: m_data(unexpected.error())
{}

template<class AnotherError>
requires (std::is_constructible_v<AnotherError, Error>)
constexpr explicit(!std::is_convertible_v<AnotherError, Error>) Expected(Unexpected<AnotherError> &&unexpected)
noexcept (std::is_nothrow_convertible_v<AnotherError, Error>)
: m_data(std::move(unexpected).error())
{}

constexpr Expected(const Expected& other)
noexcept (std::is_nothrow_copy_constructible_v<Data>)
requires (std::is_copy_constructible_v<Data>)
Expand Down Expand Up @@ -142,6 +128,20 @@ class Expected
: m_data(std::forward<OtherValue>(v))
{}

template<class AnotherError>
requires (std::is_constructible_v<const AnotherError&, Error>)
constexpr explicit(!std::is_convertible_v<const AnotherError&, Error>) Expected(const Unexpected<AnotherError> &unexpected)
noexcept (std::is_nothrow_convertible_v<const AnotherError&, Error>)
: m_data(unexpected.error())
{}

template<class AnotherError>
requires (std::is_constructible_v<AnotherError, Error>)
constexpr explicit(!std::is_convertible_v<AnotherError, Error>) Expected(Unexpected<AnotherError> &&unexpected)
noexcept (std::is_nothrow_convertible_v<AnotherError, Error>)
: m_data(std::move(unexpected).error())
{}

[[nodiscard]] constexpr bool hasValue() const {
return std::holds_alternative<Value_>(m_data);
}
Expand Down

0 comments on commit fcdced6

Please sign in to comment.