Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 6 additions & 52 deletions include/beman/optional26/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,29 +276,15 @@ class optional {

template <class U>
constexpr explicit(!std::is_convertible_v<U, T>) optional(const optional<U>& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
std::is_convertible_v<const U&, T>);

template <class U>
constexpr explicit(!std::is_convertible_v<U, T>) optional(const optional<U>& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
!std::is_convertible_v<const U&, T>);
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&>);

template <class U>
constexpr explicit(!std::is_convertible_v<U, T>) optional(optional<U>&& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && std::is_convertible_v<U &&, T>);

template <class U>
constexpr explicit(!std::is_convertible_v<U, T>) optional(optional<U>&& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && !std::is_convertible_v<U &&, T>);

template <class U>
constexpr explicit(!std::is_convertible_v<U&, T>) optional(const optional<U&>& rhs)
requires(detail::enable_from_other<T, U&, U&> && std::is_convertible_v<U&, T>);
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&>);

template <class U>
constexpr explicit(!std::is_convertible_v<U&, T>) optional(const optional<U&>& rhs)
requires(detail::enable_from_other<T, U&, U&> && !std::is_convertible_v<U&, T>);
requires(detail::enable_from_other<T, U&, U&>);

// \ref{optional.dtor}, destructor
constexpr ~optional()
Expand Down Expand Up @@ -477,19 +463,7 @@ inline constexpr optional<T>::optional(U&& u)
template <class T>
template <class U>
inline constexpr optional<T>::optional(const optional<U>& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
std::is_convertible_v<const U&, T>)
{
if (rhs.has_value()) {
construct(*rhs);
}
}

template <class T>
template <class U>
inline constexpr optional<T>::optional(const optional<U>& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
!std::is_convertible_v<const U&, T>)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&>)
{
if (rhs.has_value()) {
construct(*rhs);
Expand All @@ -500,37 +474,17 @@ inline constexpr optional<T>::optional(const optional<U>& rhs)
template <class T>
template <class U>
inline constexpr optional<T>::optional(optional<U>&& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && std::is_convertible_v<U &&, T>)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&>)
{
if (rhs.has_value()) {
construct(std::move(*rhs));
}
}

template <class T>
template <class U>
inline constexpr optional<T>::optional(optional<U>&& rhs)
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && !std::is_convertible_v<U &&, T>)
{
if (rhs.has_value()) {
construct(std::move(*rhs));
}
}

template <class T>
template <class U>
inline constexpr optional<T>::optional(const optional<U&>& rhs)
requires(detail::enable_from_other<T, U&, U&> && std::is_convertible_v<U&, T>)
{
if (rhs.has_value()) {
construct(*rhs);
}
}

template <class T>
template <class U>
inline constexpr optional<T>::optional(const optional<U&>& rhs)
requires(detail::enable_from_other<T, U&, U&> && !std::is_convertible_v<U&, T>)
requires(detail::enable_from_other<T, U&, U&>)
{
if (rhs.has_value()) {
construct(*rhs);
Expand Down
Loading