int main(int argc, char* argv[]) { { true_value tr; tr = check<__has_trivial_assign(A1)>::f(); } { true_value tr; tr = check<__has_trivial_assign(A2)>::f(); } { false_value tr; tr = check<__has_trivial_assign(A3)>::f(); } { false_value tr; tr = check<__has_trivial_assign(A4)>::f(); } { false_value tr; tr = check<__has_trivial_assign(A5)>::f(); } { false_value tr; tr = check<__has_trivial_assign(A6)>::f(); } }
concept bool Trivially_assignable() { return __has_trivial_assign(T); }
// PR c++/39475 struct I; // { dg-error "forward declaration" } struct C { }; bool nas1 = __has_nothrow_assign(I); // { dg-error "incomplete type" } bool nas2 = __has_nothrow_assign(C[]); bool nas3 = __has_nothrow_assign(I[]); // { dg-error "incomplete type" } bool nas4 = __has_nothrow_assign(void); bool nas5 = __has_nothrow_assign(const void); bool tas1 = __has_trivial_assign(I); // { dg-error "incomplete type" } bool tas2 = __has_trivial_assign(C[]); bool tas3 = __has_trivial_assign(I[]); // { dg-error "incomplete type" } bool tas4 = __has_trivial_assign(void); bool tas5 = __has_trivial_assign(const void); bool nco1 = __has_nothrow_constructor(I); // { dg-error "incomplete type" } bool nco2 = __has_nothrow_constructor(C[]); bool nco3 = __has_nothrow_constructor(I[]); // { dg-error "incomplete type" } 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[]);
}; 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() {} }; S<lit> s_lit; // ok