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

Side by Side Diff: third_party/WebKit/Source/platform/wtf/SizeAssertions.h

Issue 2755793004: Move files in wtf/ to platform/wtf/ (Part 3). (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WTF_SizeAssertions_h 5 #ifndef WTF_SizeAssertions_h
6 #define WTF_SizeAssertions_h 6 #define WTF_SizeAssertions_h
7 7
8 namespace WTF { 8 namespace WTF {
9 9
10 // The ASSERT_SIZE macro can be used to check that a given struct is the same 10 // The ASSERT_SIZE macro can be used to check that a given struct is the same
11 // size as a class. This is useful to visualize where the space is being used in 11 // size as a class. This is useful to visualize where the space is being used in
12 // a class, as well as give a useful compile error message when the size doesn't 12 // a class, as well as give a useful compile error message when the size doesn't
13 // match the expected value. 13 // match the expected value.
14 template <class T, class U> 14 template <class T, class U>
15 struct assert_size { 15 struct assert_size {
16 template <int ActualSize, int ExpectedSize> 16 template <int ActualSize, int ExpectedSize>
17 struct assertSizeEqual { 17 struct assertSizeEqual {
18 static_assert(ActualSize == ExpectedSize, "Class should stay small"); 18 static_assert(ActualSize == ExpectedSize, "Class should stay small");
19 static const bool innerValue = true; 19 static const bool innerValue = true;
20 }; 20 };
21 static const bool value = assertSizeEqual<sizeof(T), sizeof(U)>::innerValue; 21 static const bool value = assertSizeEqual<sizeof(T), sizeof(U)>::innerValue;
22 }; 22 };
23 23
24 } // namespace WTF 24 } // namespace WTF
25 25
26 #define ASSERT_SIZE(className, sameSizeAsClassName) \ 26 #define ASSERT_SIZE(className, sameSizeAsClassName) \
27 static_assert(WTF::assert_size<className, sameSizeAsClassName>::value, ""); 27 static_assert(WTF::assert_size<className, sameSizeAsClassName>::value, "");
28 28
29 #endif // WTF_SizeAssertions_h 29 #endif // WTF_SizeAssertions_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/Optional.h ('k') | third_party/WebKit/Source/platform/wtf/StaticConstructors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698