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

Side by Side Diff: base/macros.h

Issue 647433004: Don't define ARRAYSIZE_UNSAFE except in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asdf Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This file contains macros and macro-like constructs (e.g., templates) that 5 // This file contains macros and macro-like constructs (e.g., templates) that
6 // are commonly used throughout Chromium source. (It may also contain things 6 // are commonly used throughout Chromium source. (It may also contain things
7 // that are closely related to things that are commonly used that belong in this 7 // that are closely related to things that are commonly used that belong in this
8 // file.) 8 // file.)
9 9
10 #ifndef BASE_MACROS_H_ 10 #ifndef BASE_MACROS_H_
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // template overloads: the final frontier. 62 // template overloads: the final frontier.
63 #ifndef _MSC_VER 63 #ifndef _MSC_VER
64 template <typename T, size_t N> 64 template <typename T, size_t N>
65 char (&ArraySizeHelper(const T (&array)[N]))[N]; 65 char (&ArraySizeHelper(const T (&array)[N]))[N];
66 #endif 66 #endif
67 67
68 #define arraysize(array) (sizeof(ArraySizeHelper(array))) 68 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
69 69
70 // DEPRECATED: Just use |arraysize()|, now that C++11 has removed the 70 // DEPRECATED: Just use |arraysize()|, now that C++11 has removed the
71 // limitations that forced the use of |ARRAYSIZE_UNSAFE()|. 71 // limitations that forced the use of |ARRAYSIZE_UNSAFE()|.
72 // TODO(viettrungluu): Convert all instances and delete. crbug.com/423134 72 // TODO(viettrungluu): Convert all instances and delete. (The only uses are now
73 // in Blink; the ifdef is to prevent it from reappearing in Chromium.)
74 // crbug.com/423134
75 #if defined(BLINK_PLATFORM) || defined(BLINK_PLATFORM_IMPLEMENTATION)
73 #define ARRAYSIZE_UNSAFE(a) arraysize(a) 76 #define ARRAYSIZE_UNSAFE(a) arraysize(a)
77 #endif
74 78
75 79
76 // Use implicit_cast as a safe version of static_cast or const_cast 80 // Use implicit_cast as a safe version of static_cast or const_cast
77 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo 81 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo
78 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to 82 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to
79 // a const pointer to Foo). 83 // a const pointer to Foo).
80 // When you use implicit_cast, the compiler checks that the cast is safe. 84 // When you use implicit_cast, the compiler checks that the cast is safe.
81 // Such explicit implicit_casts are necessary in surprisingly many 85 // Such explicit implicit_casts are necessary in surprisingly many
82 // situations where C++ demands an exact type match instead of an 86 // situations where C++ demands an exact type match instead of an
83 // argument type convertible to a target type. 87 // argument type convertible to a target type.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 210
207 // Use these to declare and define a static local variable (static T;) so that 211 // Use these to declare and define a static local variable (static T;) so that
208 // it is leaked so that its destructors are not called at exit. If you need 212 // it is leaked so that its destructors are not called at exit. If you need
209 // thread-safe initialization, use base/lazy_instance.h instead. 213 // thread-safe initialization, use base/lazy_instance.h instead.
210 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ 214 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
211 static type& name = *new type arguments 215 static type& name = *new type arguments
212 216
213 } // base 217 } // base
214 218
215 #endif // BASE_MACROS_H_ 219 #endif // BASE_MACROS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698