diff --git a/octa/traits.h b/octa/traits.h index 7027972..f7bd752 100644 --- a/octa/traits.h +++ b/octa/traits.h @@ -294,6 +294,43 @@ namespace octa { template struct HasVirtualDestructor: IntegralConstant {}; + /* is destructible - libc++ used as ref */ + + template struct IsDestructibleApply { typedef int type; }; + + template struct IsDestructorWellformed { + template static char test(typename IsDestructibleApply< + decltype(declval().~TT()) + >::type); + + template static int test(...); + + static constexpr bool value = (sizeof(test(12)) == sizeof(char)); + }; + + template struct DestructibleImpl; + + template + struct DestructibleImpl: IntegralConstant::type>::value + > {}; + + template + struct DestructibleImpl: true_t {}; + + template struct DestructibleFalse; + + template struct DestructibleFalse + : DestructibleImpl::value> {}; + + template struct DestructibleFalse: false_t {}; + + template + struct IsDestructible: DestructibleFalse::value> {}; + + template struct IsDestructible: false_t {}; + template< > struct IsDestructible: false_t {}; + /* is trivially constructible */ template @@ -475,6 +512,29 @@ namespace octa { typename internal::AddRvalueReference::type > {}; + /* is nothrow destructible */ + + template struct IsNothrowDestructibleBase; + + template + struct IsNothrowDestructibleBase: IntegralConstant().~T()) + > {}; + + template + struct IsNothrowDestructible: IsNothrowDestructibleBase::value + > {}; + + template + struct IsNothrowDestructible: IsNothrowDestructible {}; + + template + struct IsNothrowDestructible: IsNothrowDestructible {}; + + template + struct IsNothrowDestructible: IsNothrowDestructible {}; + /* is base of */ template