diff --git a/AK/Platform.h b/AK/Platform.h index f8fcaa3d6cb..e0e08b4331c 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -249,6 +249,13 @@ # define NO_UNIQUE_ADDRESS [[no_unique_address]] #endif +#if defined(AK_OS_WINDOWS) +// https://learn.microsoft.com/en-us/cpp/cpp/empty-bases?view=msvc-170 +# define AK_COMPACT_EMPTY_BASES __declspec(empty_bases) +#else +# define AK_COMPACT_EMPTY_BASES +#endif + // GCC doesn't have __has_feature but clang does #ifndef __has_feature # define __has_feature(...) 0 diff --git a/AK/Tuple.h b/AK/Tuple.h index df8a3d26fc4..2ae3c92d724 100644 --- a/AK/Tuple.h +++ b/AK/Tuple.h @@ -59,7 +59,7 @@ private: }; template -struct Tuple : Tuple { +struct AK_COMPACT_EMPTY_BASES Tuple : Tuple { template Tuple(FirstT&& first, RestT&&... rest) @@ -113,7 +113,7 @@ private: namespace AK { template -struct Tuple : Detail::Tuple { +struct AK_COMPACT_EMPTY_BASES Tuple : Detail::Tuple { using Types = TypeList; using Detail::Tuple::Tuple; using Indices = MakeIndexSequence; diff --git a/AK/Variant.h b/AK/Variant.h index a04a1daf902..a03d57c112f 100644 --- a/AK/Variant.h +++ b/AK/Variant.h @@ -478,7 +478,7 @@ private: } template - struct Visitor : Fs... { + struct AK_COMPACT_EMPTY_BASES Visitor : Fs... { using Types = TypeList; Visitor(Fs&&... args)