int main(int argc, char* argv[])
{
    {
        true_value tr;
        tr = check<__has_trivial_destructor(A1)>::f();
    }

    {
        true_value tr;
        tr = check<__has_trivial_destructor(A2)>::f();
    }

    {
        false_value tr;
        tr = check<__has_trivial_destructor(A3)>::f();
    }

    {
        false_value tr;
        tr = check<__has_trivial_destructor(A4)>::f();
    }

    {
        false_value tr;
        tr = check<__has_trivial_destructor(A5)>::f();
    }

    {
        false_value tr;
        tr = check<__has_trivial_destructor(A6)>::f();
    }
}
Ejemplo n.º 2
0
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 tde5 = __has_trivial_destructor(const void);

bool abs1 = __is_abstract(I); // { dg-error "incomplete type" }
bool abs2 = __is_abstract(C[]);
bool abs3 = __is_abstract(I[]); // { dg-error "incomplete type" }
bool abs4 = __is_abstract(void);
bool abs5 = __is_abstract(const void);

bool pod1 = __is_pod(I); // { dg-error "incomplete type" }
bool pod2 = __is_pod(C[]);
bool pod3 = __is_pod(I[]); // { dg-error "incomplete type" }
bool pod4 = __is_pod(void);
Ejemplo n.º 3
0
template <typename am> void aq(am ao, am ap) {
  typedef typename j<am>::k ar;
  al<__has_trivial_destructor(ar)>::an(ao, ap);
}
Ejemplo n.º 4
0
 concept bool Trivially_destructible() { return __has_trivial_destructor(T); }
Ejemplo n.º 5
0
  bar(bar&&);
  bar& operator = (const bar&);
  bar& operator = (bar&&);
  ~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;
Ejemplo n.º 6
0
 bool
 f()
 { return !!__has_trivial_destructor(T); }
Ejemplo n.º 7
0
    bool
    f()
    { return !!__has_trivial_destructor(T); }
  };

template<typename T>
  class My2
  {
  public:
    static const bool trait = __has_trivial_destructor(T);
  };

template<typename T>
  const bool My2<T>::trait;

template<typename T, bool b = __has_trivial_destructor(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; }
  };
Ejemplo n.º 8
0
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
// expected-no-diagnostics
struct T1 {
};
static_assert(__has_trivial_destructor(T1), "T1 has trivial destructor!");

struct T2 {
  ~T2();
};
static_assert(!__has_trivial_destructor(T2), "T2 has a user-declared destructor!");

struct T3 {
  virtual void f();
};
static_assert(__has_trivial_destructor(T3), "T3 has a virtual function (but still a trivial destructor)!");

struct T4 : virtual T3 {
};
static_assert(__has_trivial_destructor(T4), "T4 has a virtual base class! (but still a trivial destructor)!");

struct T5 : T1 {
};
static_assert(__has_trivial_destructor(T5), "All the direct base classes of T5 have trivial destructors!");

struct T6 {
  T5 t5;
  T1 t1[2][2];
  static T2 t2;
};
static_assert(__has_trivial_destructor(T6), "All nonstatic data members of T6 have trivial destructors!");