diff --git a/include/boost/system/result.hpp b/include/boost/system/result.hpp index fb2f9bd..33eec39 100644 --- a/include/boost/system/result.hpp +++ b/include/boost/system/result.hpp @@ -122,7 +122,7 @@ public: template::value && !(detail::is_errc_t::value && std::is_arithmetic::value) && - !std::is_constructible::value, int>::type = 0> + !std::is_convertible::value, int>::type = 0> constexpr result( A&& a ) noexcept( std::is_nothrow_constructible::value ) : v_( in_place_value, std::forward(a) ) @@ -132,7 +132,7 @@ public: // implicit, error template::value && - !std::is_constructible::value, int>::type = 0> + !std::is_convertible::value, int>::type = 0> constexpr result( A&& a ) noexcept( std::is_nothrow_constructible::value ) : v_( in_place_error, std::forward(a) ) diff --git a/test/result_error_construct.cpp b/test/result_error_construct.cpp index 8cee5a9..af9de73 100644 --- a/test/result_error_construct.cpp +++ b/test/result_error_construct.cpp @@ -146,8 +146,14 @@ int main() BOOST_TEST_TRAIT_TRUE((std::is_constructible, int>)); BOOST_TEST_TRAIT_FALSE((std::is_convertible>)); - BOOST_TEST_TRAIT_FALSE((std::is_constructible, int>)); - BOOST_TEST_TRAIT_FALSE((std::is_convertible>)); + // We'd like this to be false due to the ambiguity caused by X having + // an explicit constructor taking an int, which should be viable in this + // context, but the implicit constructor is enabled, and there's no way to + // disallow it + // + // BOOST_TEST_TRAIT_FALSE((std::is_constructible, int>)); + + BOOST_TEST_TRAIT_TRUE((std::is_convertible>)); } {