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

Side by Side Diff: src/base/flags.h

Issue 1088993003: Replace OVERRIDE->override and FINAL->final since we now require C++11. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « src/base/cpu.cc ('k') | src/base/platform/condition-variable.h » ('j') | 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 V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 V8_BASE_FLAGS_H_ 5 #ifndef V8_BASE_FLAGS_H_
6 #define V8_BASE_FLAGS_H_ 6 #define V8_BASE_FLAGS_H_
7 7
8 #include "src/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace base { 11 namespace base {
12 12
13 // The Flags class provides a type-safe way of storing OR-combinations of enum 13 // The Flags class provides a type-safe way of storing OR-combinations of enum
14 // values. The Flags<T, S> class is a template class, where T is an enum type, 14 // values. The Flags<T, S> class is a template class, where T is an enum type,
15 // and S is the underlying storage type (usually int). 15 // and S is the underlying storage type (usually int).
16 // 16 //
17 // The traditional C++ approach for storing OR-combinations of enum values is to 17 // The traditional C++ approach for storing OR-combinations of enum values is to
18 // use an int or unsigned int variable. The inconvenience with this approach is 18 // use an int or unsigned int variable. The inconvenience with this approach is
19 // that there's no type checking at all; any enum value can be OR'd with any 19 // that there's no type checking at all; any enum value can be OR'd with any
20 // other enum value and passed on to a function that takes an int or unsigned 20 // other enum value and passed on to a function that takes an int or unsigned
21 // int. 21 // int.
22 template <typename T, typename S = int> 22 template <typename T, typename S = int>
23 class Flags FINAL { 23 class Flags final {
24 public: 24 public:
25 typedef T flag_type; 25 typedef T flag_type;
26 typedef S mask_type; 26 typedef S mask_type;
27 27
28 Flags() : mask_(0) {} 28 Flags() : mask_(0) {}
29 Flags(flag_type flag) // NOLINT(runtime/explicit) 29 Flags(flag_type flag) // NOLINT(runtime/explicit)
30 : mask_(static_cast<S>(flag)) {} 30 : mask_(static_cast<S>(flag)) {}
31 explicit Flags(mask_type mask) : mask_(static_cast<S>(mask)) {} 31 explicit Flags(mask_type mask) : mask_(static_cast<S>(mask)) {}
32 32
33 Flags& operator&=(const Flags& flags) { 33 Flags& operator&=(const Flags& flags) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 inline Type operator^(Type::flag_type lhs, const Type& rhs) { \ 102 inline Type operator^(Type::flag_type lhs, const Type& rhs) { \
103 return rhs ^ lhs; \ 103 return rhs ^ lhs; \
104 } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \ 104 } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \
105 ALLOW_UNUSED_TYPE; \ 105 ALLOW_UNUSED_TYPE; \
106 inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {} 106 inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {}
107 107
108 } // namespace base 108 } // namespace base
109 } // namespace v8 109 } // namespace v8
110 110
111 #endif // V8_BASE_FLAGS_H_ 111 #endif // V8_BASE_FLAGS_H_
OLDNEW
« no previous file with comments | « src/base/cpu.cc ('k') | src/base/platform/condition-variable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698