Skip to content

Commit b383b1a

Browse files
authored
Merge pull request #100 from steve-downey/dup-funcs
Remove redundant overloads on is_convertible
2 parents 2f944fa + cb33563 commit b383b1a

File tree

1 file changed

+6
-52
lines changed

1 file changed

+6
-52
lines changed

include/beman/optional26/optional.hpp

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -276,29 +276,15 @@ class optional {
276276

277277
template <class U>
278278
constexpr explicit(!std::is_convertible_v<U, T>) optional(const optional<U>& rhs)
279-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
280-
std::is_convertible_v<const U&, T>);
281-
282-
template <class U>
283-
constexpr explicit(!std::is_convertible_v<U, T>) optional(const optional<U>& rhs)
284-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
285-
!std::is_convertible_v<const U&, T>);
279+
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&>);
286280

287281
template <class U>
288282
constexpr explicit(!std::is_convertible_v<U, T>) optional(optional<U>&& rhs)
289-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && std::is_convertible_v<U &&, T>);
290-
291-
template <class U>
292-
constexpr explicit(!std::is_convertible_v<U, T>) optional(optional<U>&& rhs)
293-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && !std::is_convertible_v<U &&, T>);
294-
295-
template <class U>
296-
constexpr explicit(!std::is_convertible_v<U&, T>) optional(const optional<U&>& rhs)
297-
requires(detail::enable_from_other<T, U&, U&> && std::is_convertible_v<U&, T>);
283+
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&>);
298284

299285
template <class U>
300286
constexpr explicit(!std::is_convertible_v<U&, T>) optional(const optional<U&>& rhs)
301-
requires(detail::enable_from_other<T, U&, U&> && !std::is_convertible_v<U&, T>);
287+
requires(detail::enable_from_other<T, U&, U&>);
302288

303289
// \ref{optional.dtor}, destructor
304290
constexpr ~optional()
@@ -477,19 +463,7 @@ inline constexpr optional<T>::optional(U&& u)
477463
template <class T>
478464
template <class U>
479465
inline constexpr optional<T>::optional(const optional<U>& rhs)
480-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
481-
std::is_convertible_v<const U&, T>)
482-
{
483-
if (rhs.has_value()) {
484-
construct(*rhs);
485-
}
486-
}
487-
488-
template <class T>
489-
template <class U>
490-
inline constexpr optional<T>::optional(const optional<U>& rhs)
491-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&> &&
492-
!std::is_convertible_v<const U&, T>)
466+
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, const U&>)
493467
{
494468
if (rhs.has_value()) {
495469
construct(*rhs);
@@ -500,37 +474,17 @@ inline constexpr optional<T>::optional(const optional<U>& rhs)
500474
template <class T>
501475
template <class U>
502476
inline constexpr optional<T>::optional(optional<U>&& rhs)
503-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && std::is_convertible_v<U &&, T>)
477+
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&>)
504478
{
505479
if (rhs.has_value()) {
506480
construct(std::move(*rhs));
507481
}
508482
}
509483

510-
template <class T>
511-
template <class U>
512-
inline constexpr optional<T>::optional(optional<U>&& rhs)
513-
requires(!std::is_reference_v<U> && detail::enable_from_other<T, U, U &&> && !std::is_convertible_v<U &&, T>)
514-
{
515-
if (rhs.has_value()) {
516-
construct(std::move(*rhs));
517-
}
518-
}
519-
520-
template <class T>
521-
template <class U>
522-
inline constexpr optional<T>::optional(const optional<U&>& rhs)
523-
requires(detail::enable_from_other<T, U&, U&> && std::is_convertible_v<U&, T>)
524-
{
525-
if (rhs.has_value()) {
526-
construct(*rhs);
527-
}
528-
}
529-
530484
template <class T>
531485
template <class U>
532486
inline constexpr optional<T>::optional(const optional<U&>& rhs)
533-
requires(detail::enable_from_other<T, U&, U&> && !std::is_convertible_v<U&, T>)
487+
requires(detail::enable_from_other<T, U&, U&>)
534488
{
535489
if (rhs.has_value()) {
536490
construct(*rhs);

0 commit comments

Comments
 (0)