diff --git a/ostd/type_traits.hh b/ostd/type_traits.hh index 47403f4..467fa8c 100644 --- a/ostd/type_traits.hh +++ b/ostd/type_traits.hh @@ -439,6 +439,51 @@ constexpr bool IsMoveConstructible = IsConstructible >; +/* is nothrow constructible */ + +namespace detail { + template + constexpr bool NothrowCtibleCore = false; + + template + constexpr bool NothrowCtibleCore + = noexcept(T(declval_in()...)); + + template void implicit_conv_to(T) noexcept {} + + template + constexpr bool NothrowCtibleCore + = noexcept(ostd::detail::implicit_conv_to(declval_in())); + + template + constexpr bool NothrowCtibleCore = false; +} /* namespace detail */ + +template constexpr bool IsNothrowConstructible + = detail::NothrowCtibleCore, IsReference, T, A...>; + +template constexpr bool IsNothrowConstructible + = detail::NothrowCtibleCore, IsReference, T>; + +/* is nothrow default constructible */ + +template +constexpr bool IsNothrowDefaultConstructible = IsNothrowConstructible; + +/* is nothrow copy constructible */ + +template +constexpr bool IsNothrowCopyConstructible = IsNothrowConstructible> +>; + +/* is nothrow move constructible */ + +template +constexpr bool IsNothrowMoveConstructible = IsNothrowConstructible +>; + /* is assignable */ namespace detail { @@ -476,6 +521,37 @@ constexpr bool IsMoveAssignable = IsAssignable< AddRvalueReference const >; +/* is nothrow assignable */ + +namespace detail { + template + constexpr bool NothrowAssignableCore = false; + + template + constexpr bool NothrowAssignableCore = false; + + template + constexpr bool NothrowAssignableCore + = noexcept(declval_in() = declval_in()); +} + +template constexpr bool IsNothrowAssignable + = detail::NothrowAssignableCore, T, A>; + +/* is nothrow copy assignable */ + +template +constexpr bool IsNothrowCopyAssignable = IsNothrowAssignable< + AddLvalueReference, AddLvalueReference> +>; + +/* is nothrow move assignable */ + +template +constexpr bool IsNothrowMoveAssignable = IsNothrowAssignable< + AddLvalueReference, AddRvalueReference +>; + /* is destructible */ namespace detail { @@ -517,6 +593,23 @@ namespace detail { template constexpr bool IsDestructible = detail::IsDestructibleBase; +/* is nothrow destructible */ + +namespace detail { + template constexpr bool NothrowDtibleCore = false; + + template constexpr bool NothrowDtibleCore = false; + + template constexpr bool NothrowDtibleCore + = noexcept(declval_in().~T()); +} + +template constexpr bool IsNothrowDestructible + = detail::NothrowDtibleCore, T>; + +template constexpr bool IsNothrowDestructible + = IsNothrowDestructible; + /* is trivially constructible */ namespace detail {