has_nothrow_default_constructor hooked up to clang. Filed http://llvm.org/bugs/show_bug.cgi?id=8101 to take care of void, arrays of incomplete types, and classes with virtual destructors which don't work yet. If there is some reasons we don't want to handle these types in the compiler, I can handle them in the library.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@113217 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2010-09-07 17:15:17 +00:00
parent 2fd6d25bf1
commit 6fd2e09b36
2 changed files with 13 additions and 3 deletions

View File

@ -714,7 +714,17 @@ template <class _Tp> struct has_trivial_default_constructor
// has_nothrow_default_constructor
template <class _Tp> struct has_nothrow_default_constructor : public has_trivial_default_constructor<_Tp> {};
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 || defined(__clang__)
template <class _Tp> struct has_nothrow_default_constructor
: public integral_constant<bool, __has_nothrow_constructor(_Tp)> {};
#else // __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 || defined(__clang__)
template <class _Tp> struct has_nothrow_default_constructor
: public has_trivial_default_constructor<_Tp> {};
#endif // __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 || defined(__clang__)
// has_trivial_copy_constructor

View File

@ -62,16 +62,16 @@ int main()
test_has_not_nothrow_default_constructor<void>();
test_has_not_nothrow_default_constructor<int&>();
test_has_not_nothrow_default_constructor<A>();
test_has_not_nothrow_default_constructor<char[]>();
test_has_not_nothrow_default_constructor<Abstract>();
test_has_nothrow_default_constructor<Union>();
test_has_nothrow_default_constructor<Abstract>();
test_has_nothrow_default_constructor<Empty>();
test_has_nothrow_default_constructor<int>();
test_has_nothrow_default_constructor<double>();
test_has_nothrow_default_constructor<int*>();
test_has_nothrow_default_constructor<const int*>();
test_has_nothrow_default_constructor<char[3]>();
test_has_nothrow_default_constructor<char[3]>();
test_has_nothrow_default_constructor<NotEmpty>();
test_has_nothrow_default_constructor<bit_zero>();
}