Is there a way to write a compile-time assertion that checks if some type has any padding in it?
For example:
struct This_Should_Succeed
{
int a;
Since C++17 you might be able to use std::has_unique_object_representations.
#include
static_assert(std::has_unique_object_representations_v); // succeeds
static_assert(std::has_unique_object_representations_v); // fails
Although, this might not do exactly what you want it to do. Check the linked cppreference page for details.