bool nco4 = __has_nothrow_constructor(void); bool nco5 = __has_nothrow_constructor(const void); bool tco1 = __has_trivial_constructor(I); // { dg-error "incomplete type" } bool tco2 = __has_trivial_constructor(C[]); bool tco3 = __has_trivial_constructor(I[]); // { dg-error "incomplete type" } bool tco4 = __has_trivial_constructor(void); bool tco5 = __has_trivial_constructor(const void); bool ncp1 = __has_nothrow_copy(I); // { dg-error "incomplete type" } bool ncp2 = __has_nothrow_copy(C[]); bool ncp3 = __has_nothrow_copy(I[]); // { dg-error "incomplete type" } bool ncp4 = __has_nothrow_copy(void); bool ncp5 = __has_nothrow_copy(const void); bool tcp1 = __has_trivial_copy(I); // { dg-error "incomplete type" } bool tcp2 = __has_trivial_copy(C[]); bool tcp3 = __has_trivial_copy(I[]); // { dg-error "incomplete type" } bool tcp4 = __has_trivial_copy(void); bool tcp5 = __has_trivial_copy(const void); bool vde1 = __has_virtual_destructor(I); // { dg-error "incomplete type" } bool vde2 = __has_virtual_destructor(C[]); bool vde3 = __has_virtual_destructor(I[]); // { dg-error "incomplete type" } bool vde4 = __has_virtual_destructor(void); bool vde5 = __has_virtual_destructor(const void); bool tde1 = __has_trivial_destructor(I); // { dg-error "incomplete type" } bool tde2 = __has_trivial_destructor(C[]); bool tde3 = __has_trivial_destructor(I[]); // { dg-error "incomplete type" } bool tde4 = __has_trivial_destructor(void);
bool f() { return !!__has_trivial_copy(T); }
bool f() { return !!__has_trivial_copy(T); } }; template<typename T> class My2 { public: static const bool trait = __has_trivial_copy(T); }; template<typename T> const bool My2<T>::trait; template<typename T, bool b = __has_trivial_copy(T)> struct My3_help { static const bool trait = b; }; template<typename T, bool b> const bool My3_help<T, b>::trait; template<typename T> class My3 { public: bool f() { return My3_help<T>::trait; } };
#include <type_traits> struct MyPOD { int x; }; static_assert( __has_trivial_copy( MyPOD ), "is_trivially_copyable does not work correctly!" ); int main( int argc, char** argv ) { return 0; }
concept bool Trivially_copyable() { return __has_trivial_copy(T); }
~bar(); }; bar::bar() = default; bar::bar(const bar&) = default; bar::bar(bar&&) = default; bar& bar::operator = (const bar&) = default; bar& bar::operator = (bar&&) = default; bar::~bar() = default; static_assert(__is_trivial(foo), "foo should be trivial"); static_assert(!__has_trivial_destructor(bar), "bar's destructor isn't trivial"); static_assert(!__has_trivial_constructor(bar), "bar's default constructor isn't trivial"); static_assert(!__has_trivial_copy(bar), "bar has no trivial copy"); static_assert(!__has_trivial_assign(bar), "bar has no trivial assign"); void tester() { foo f, g(f); bar b, c(b); f = g; b = c; } template<typename T> struct S : T { constexpr S() = default; constexpr S(const S&) = default; constexpr S(S&&) = default; }; struct lit { constexpr lit() {} };