Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: Source/wtf/SizeAssertions.h

Issue 1317143005: [WIP] do something :-) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/text/BidiContext.cpp ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifndef WTF_SizeAssertions_h
2 #define WTF_SizeAssertions_h
3
4 #include "wtf/CPU.h"
5
6 namespace WTF {
7
8 template<class T, int Expected32BitSize, int Expected64BitSize> struct assert_si ze {
9 template<int ActualSize, int ExpectedSize> class assert_equal {
10 static_assert(ActualSize == ExpectedSize,
11 "Object size doesn't match expected value, think before making them bigger :-)");
12 };
13 #if CPU(32BIT)
14 assert_equal<sizeof(T), Expected32BitSize> tmp;
15 #else
16 assert_equal<sizeof(T), Expected64BitSize> tmp;
17 #endif
18 enum { Dummy = 1 };
19 };
20
21 } // namespace WTF
22
23 // Some objects have additional members when asserts are enabled, so only check
24 // sizes when they are disabled.
25 #if ENABLE(ASSERT)
26 #define ASSERT_SIZE(className, expected32BitSize, expected64BitSize)
27 #else
28 #define ASSERT_SIZE(className, expected32BitSize, expected64BitSize) \
29 static_assert(WTF::assert_size<className, expected32BitSize, expected64BitSi ze>::Dummy, "");
30 #endif
31
32 #endif /* WTF_SizeAssertions_h */
OLDNEW
« no previous file with comments | « Source/platform/text/BidiContext.cpp ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698