Should s
be considered a trivial type according to the C++20 standard?
#include <type_traits>
struct s {
s() = default;
s(auto...) {}
};
static_assert(std::is_trivial_v<s>); // clang nope, gcc ok, msvc ok
[class.prop]/2 defines trivial class types:
A trivial class is a class that is trivially copyable and has one or more eligible default constructors ([class.default.ctor]), all of which are trivial.
[class.default.ctor]/1 defines "default constructor":
A default constructor for a class
X
is a constructor of classX
for which each parameter that is not a function parameter pack has a default argument (including the case of a constructor with no parameters). [...]
The variadic constructor for s
is a default constructor because all 0 of its non-pack parameters each have a default argument. So s
doesn't satisfy the "all of which are trivial" criterion, and is not a trivial class type.