From 9b8ce75e910555936bd876f502065d338935ac5e Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 18 Sep 2024 11:38:48 -0400 Subject: [PATCH] Update make_optional(t) as suggested by Jiang An --- include/Beman/Optional26/optional.hpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/include/Beman/Optional26/optional.hpp b/include/Beman/Optional26/optional.hpp index 960d4bf..fc99192 100644 --- a/include/Beman/Optional26/optional.hpp +++ b/include/Beman/Optional26/optional.hpp @@ -232,24 +232,20 @@ template inline constexpr bool is_optional = false; template inline constexpr bool is_optional> = true; + +struct specification_barrier { + explicit specification_barrier() = default; +}; } // namespace detail -template , std::decay_t, T>> -constexpr optional make_optional(U&& u) noexcept(std::is_nothrow_constructible_v) - requires std::is_constructible_v +template +constexpr optional> make_optional(T&& t) noexcept(std::is_nothrow_constructible_v, T>) + requires std::is_constructible_v, T> { - static_assert(sizeof...(Chomp) == 0, "make_optional takes at most one template argument"); - if constexpr (!std::is_void_v) { - static_assert(std::is_object_v, "make_optional's template argument must be an object type"); - static_assert(!std::is_array_v, "make_optional's template argument must be a non-array object type"); - } - return optional(std::forward(u)); + return optional>(std::forward(t)); } -template +template constexpr optional make_optional(Args&&... args) noexcept(std::is_nothrow_constructible_v) requires std::is_constructible_v { @@ -258,7 +254,7 @@ constexpr optional make_optional(Args&&... args) noexcept(std::is_nothrow_con return optional(in_place, std::forward(args)...); } -template +template constexpr optional make_optional(std::initializer_list il, Args&&... args) noexcept(std::is_nothrow_constructible_v&, Args...>)