From c92d50abbdda9833c3ee3975ee62e4971e84731e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 22 Jan 2023 02:07:28 +0200 Subject: [PATCH] Do not consider types with explicit operator bool (such as result itself) constructible from bool for the purposes of result construction. Refs #104. --- include/boost/system/result.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/boost/system/result.hpp b/include/boost/system/result.hpp index 8479b36..4084ca8 100644 --- a/include/boost/system/result.hpp +++ b/include/boost/system/result.hpp @@ -85,6 +85,10 @@ template using remove_cvref = typename std::remove_cv< typename std::re template using is_errc_t = std::is_same...>, mp11::mp_list>; +template struct is_constructible: std::is_constructible {}; +template struct is_constructible: std::is_convertible {}; +template struct is_constructible: std::is_convertible {}; + } // namespace detail // result @@ -141,9 +145,9 @@ public: // explicit, value template::value && + detail::is_constructible::value && !(detail::is_errc_t::value && std::is_arithmetic::value) && - !std::is_constructible::value && + !detail::is_constructible::value && sizeof...(A) >= 1 >::type> explicit constexpr result( A&&... a ) @@ -154,8 +158,8 @@ public: // explicit, error template::value && - std::is_constructible::value && + !detail::is_constructible::value && + detail::is_constructible::value && sizeof...(A) >= 1 >::type> explicit constexpr result( A&&... a )