@@ -27,7 +27,7 @@ Distributed under the Boost Software License, Version 1.0.
2727
2828#include " status_code_domain.hpp"
2929
30- #if (__cplusplus >= 201700 || _HAS_CXX17) && !defined(SYSTEM_ERROR2_DISABLE_STD_IN_PLACE)
30+ #if (__cplusplus >= 201700 || _HAS_CXX17) && !defined(SYSTEM_ERROR2_DISABLE_STD_IN_PLACE)
3131// 0.26
3232#include < utility> // for in_place
3333
@@ -226,6 +226,21 @@ namespace detail
226226 using type = typename impl::make_status_code_rettype<impl::types<Args...>>::type;
227227 };
228228#endif
229+
230+ template <class T > struct safe_get_make_status_code_noexcept_select
231+ {
232+ static constexpr bool value = false ;
233+ };
234+ template <> struct safe_get_make_status_code_noexcept_select <int >
235+ {
236+ static constexpr bool value = true ;
237+ };
238+ template <class T , class ... Args>
239+ using get_make_status_code_noexcept =
240+ typename std::conditional<noexcept (make_status_code(std::declval<T>(), std::declval<Args>()...)), int , void >::type;
241+ template <class T , class ... Args>
242+ using safe_get_make_status_code_noexcept =
243+ safe_get_make_status_code_noexcept_select<test_apply<get_make_status_code_noexcept, Args...>>;
229244} // namespace detail
230245
231246// ! Trait returning true if the type is a status code.
@@ -528,8 +543,8 @@ class SYSTEM_ERROR2_TRIVIAL_ABI status_code : public mixins::mixin<detail::statu
528543 && !std::is_same<typename std::decay<T>::type, in_place_t >::value // not in_place_t
529544 && is_status_code<MakeStatusCodeResult>::value // ADL makes a status code
530545 && std::is_constructible<status_code, MakeStatusCodeResult>::value)) // ADLed status code is compatible
531- constexpr status_code (T &&v, Args &&...args) noexcept (noexcept (make_status_code(std::declval<T>(),
532- std::declval< Args>() ...)) ) // NOLINT
546+ constexpr status_code (T &&v, Args &&...args) noexcept (
547+ detail::safe_get_make_status_code_noexcept<T, Args...>::value ) // NOLINT
533548 : status_code(make_status_code(static_cast <T &&>(v), static_cast<Args &&>(args)...))
534549 {
535550 }
@@ -700,8 +715,8 @@ class SYSTEM_ERROR2_TRIVIAL_ABI status_code<detail::erased<ErasedType>>
700715 && !std::is_same<typename std::decay<T>::type, value_type>::value // not copy/move of value type
701716 && is_status_code<MakeStatusCodeResult>::value // ADL makes a status code
702717 && std::is_constructible<status_code, MakeStatusCodeResult>::value)) // ADLed status code is compatible
703- constexpr status_code(T &&v, Args &&...args) noexcept (noexcept (make_status_code(std::declval<T>(),
704- std::declval< Args>() ...)) ) // NOLINT
718+ constexpr status_code(T &&v, Args &&...args) noexcept (
719+ detail::safe_get_make_status_code_noexcept<T, Args...>::value ) // NOLINT
705720 : status_code(make_status_code(static_cast <T &&>(v), static_cast<Args &&>(args)...))
706721 {
707722 }
0 commit comments