OLD | NEW |
---|---|
(Empty) | |
1 #ifndef WTF_SizeAssertions_h | |
esprehn
2016/09/08 22:25:28
missing the short copyright header
sashab
2016/09/09 01:23:47
Thanks! Also removed unused #include below.
Still
| |
2 #define WTF_SizeAssertions_h | |
3 | |
4 #include "wtf/CPU.h" | |
5 | |
6 namespace WTF { | |
7 | |
8 // The ASSERT_SIZE macro can be used to check that a given struct is the same | |
9 // size as a class. This is useful to visualize where the space is being used in | |
10 // a class, as well as give a useful compile error message when the size doesn't | |
11 // match the expected value. | |
12 template<class T, class U> struct assert_size { | |
13 template<int ActualSize, int ExpectedSize> struct assertSizeEqual { | |
14 static_assert(ActualSize == ExpectedSize, "Class should stay small"); | |
15 static const bool innerValue = true; | |
16 }; | |
17 static const bool value = assertSizeEqual<sizeof(T), sizeof(U)>::innerValue; | |
18 }; | |
19 | |
20 } // namespace WTF | |
21 | |
22 #define ASSERT_SIZE(className, sameSizeAsClassName) \ | |
23 static_assert(WTF::assert_size<className, sameSizeAsClassName>::value, ""); | |
24 | |
25 #endif // WTF_SizeAssertions_h | |
OLD | NEW |