Reputation: 42379
template<typename T>
void f()
{
if constexpr (std::is_trivial_v<T>)
{
// Does the following line never fail?
static_assert(std::is_standard_layout_v<T>);
}
}
Is std::is_standard_layout_v<T>
always true if std::is_trivial_v<T>
is true?
If no, is there any counterexamples?
Upvotes: 1
Views: 488
Reputation: 37600
#include <type_traits>
class type
{
public: int x;
private: int y;
};
static_assert(std::is_trivial_v< type >);
// not standard layout because different access level of x and y
static_assert(not std::is_standard_layout_v< type >);
Upvotes: 2