Which operation is not trivial here?

Viewed 77

Compilers agree, that the below X and Y are default-constructible, but not trivially (demo).

#include <type_traits>

struct X { int x {}; };
struct Y { int y = 0; };

static_assert(std::is_default_constructible_v<X>);
static_assert(std::is_default_constructible_v<Y>);
static_assert(!std::is_trivially_default_constructible_v<X>);
static_assert(!std::is_trivially_default_constructible_v<Y>);

Why are they not trivial? According to cppreference.com (see is_trivially_constructible) a non-trivial operation must have been called during default-construction. Which one is that?

1 Answers
Related