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

Side by Side Diff: base/basictypes.h

Issue 21910007: Fix typos in basic types header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 BASE_BASICTYPES_H_ 5 #ifndef BASE_BASICTYPES_H_
6 #define BASE_BASICTYPES_H_ 6 #define BASE_BASICTYPES_H_
7 7
8 #include <limits.h> // So we can set the bounds of our types 8 #include <limits.h> // So we can set the bounds of our types
9 #include <stddef.h> // For size_t 9 #include <stddef.h> // For size_t
10 #include <string.h> // for memcpy 10 #include <string.h> // for memcpy
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 #define DISALLOW_ASSIGN(TypeName) \ 86 #define DISALLOW_ASSIGN(TypeName) \
87 void operator=(const TypeName&) 87 void operator=(const TypeName&)
88 88
89 // A macro to disallow the copy constructor and operator= functions 89 // A macro to disallow the copy constructor and operator= functions
90 // This should be used in the private: declarations for a class 90 // This should be used in the private: declarations for a class
91 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 91 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
92 TypeName(const TypeName&); \ 92 TypeName(const TypeName&); \
93 void operator=(const TypeName&) 93 void operator=(const TypeName&)
94 94
95 // An older, deprecated, politically incorrect name for the above. 95 // An older, deprecated, politically incorrect name for the above.
96 // NOTE: The usage of this macro was baned from our code base, but some 96 // NOTE: The usage of this macro was banned from our code base, but some
97 // third_party libraries are yet using it. 97 // third_party libraries are yet using it.
98 // TODO(tfarina): Figure out how to fix the usage of this macro in the 98 // TODO(tfarina): Figure out how to fix the usage of this macro in the
99 // third_party libraries and get rid of it. 99 // third_party libraries and get rid of it.
100 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName) 100 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName)
101 101
102 // A macro to disallow all the implicit constructors, namely the 102 // A macro to disallow all the implicit constructors, namely the
103 // default constructor, copy constructor and operator= functions. 103 // default constructor, copy constructor and operator= functions.
104 // 104 //
105 // This should be used in the private: declarations for a class 105 // This should be used in the private: declarations for a class
106 // that wants to prevent anyone from instantiating it. This is 106 // that wants to prevent anyone from instantiating it. This is
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) 178 static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
179 179
180 180
181 // Use implicit_cast as a safe version of static_cast or const_cast 181 // Use implicit_cast as a safe version of static_cast or const_cast
182 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo 182 // for upcasting in the type hierarchy (i.e. casting a pointer to Foo
183 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to 183 // to a pointer to SuperclassOfFoo or casting a pointer to Foo to
184 // a const pointer to Foo). 184 // a const pointer to Foo).
185 // When you use implicit_cast, the compiler checks that the cast is safe. 185 // When you use implicit_cast, the compiler checks that the cast is safe.
186 // Such explicit implicit_casts are necessary in surprisingly many 186 // Such explicit implicit_casts are necessary in surprisingly many
187 // situations where C++ demands an exact type match instead of an 187 // situations where C++ demands an exact type match instead of an
188 // argument type convertable to a target type. 188 // argument type convertible to a target type.
189 // 189 //
190 // The From type can be inferred, so the preferred syntax for using 190 // The From type can be inferred, so the preferred syntax for using
191 // implicit_cast is the same as for static_cast etc.: 191 // implicit_cast is the same as for static_cast etc.:
192 // 192 //
193 // implicit_cast<ToType>(expr) 193 // implicit_cast<ToType>(expr)
194 // 194 //
195 // implicit_cast would have been part of the C++ standard library, 195 // implicit_cast would have been part of the C++ standard library,
196 // but the proposal was submitted too late. It will probably make 196 // but the proposal was submitted too late. It will probably make
197 // its way into the language in the future. 197 // its way into the language in the future.
198 template<typename To, typename From> 198 template<typename To, typename From>
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // int i = * reinterpret_cast<int*>(&f); // WRONG 281 // int i = * reinterpret_cast<int*>(&f); // WRONG
282 // 282 //
283 // The address-casting method actually produces undefined behavior 283 // The address-casting method actually produces undefined behavior
284 // according to ISO C++ specification section 3.10 -15 -. Roughly, this 284 // according to ISO C++ specification section 3.10 -15 -. Roughly, this
285 // section says: if an object in memory has one type, and a program 285 // section says: if an object in memory has one type, and a program
286 // accesses it with a different type, then the result is undefined 286 // accesses it with a different type, then the result is undefined
287 // behavior for most values of "different type". 287 // behavior for most values of "different type".
288 // 288 //
289 // This is true for any cast syntax, either *(int*)&f or 289 // This is true for any cast syntax, either *(int*)&f or
290 // *reinterpret_cast<int*>(&f). And it is particularly true for 290 // *reinterpret_cast<int*>(&f). And it is particularly true for
291 // conversions betweeen integral lvalues and floating-point lvalues. 291 // conversions between integral lvalues and floating-point lvalues.
292 // 292 //
293 // The purpose of 3.10 -15- is to allow optimizing compilers to assume 293 // The purpose of 3.10 -15- is to allow optimizing compilers to assume
294 // that expressions with different types refer to different memory. gcc 294 // that expressions with different types refer to different memory. gcc
295 // 4.0.1 has an optimizer that takes advantage of this. So a 295 // 4.0.1 has an optimizer that takes advantage of this. So a
296 // non-conforming program quietly produces wildly incorrect output. 296 // non-conforming program quietly produces wildly incorrect output.
297 // 297 //
298 // The problem is not the use of reinterpret_cast. The problem is type 298 // The problem is not the use of reinterpret_cast. The problem is type
299 // punning: holding an object in memory of one type and reading its bits 299 // punning: holding an object in memory of one type and reading its bits
300 // back using a different type. 300 // back using a different type.
301 // 301 //
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 // Use these to declare and define a static local variable (static T;) so that 361 // Use these to declare and define a static local variable (static T;) so that
362 // it is leaked so that its destructors are not called at exit. If you need 362 // it is leaked so that its destructors are not called at exit. If you need
363 // thread-safe initialization, use base/lazy_instance.h instead. 363 // thread-safe initialization, use base/lazy_instance.h instead.
364 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ 364 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
365 static type& name = *new type arguments 365 static type& name = *new type arguments
366 366
367 } // base 367 } // base
368 368
369 #endif // BASE_BASICTYPES_H_ 369 #endif // BASE_BASICTYPES_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