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: sync/internal_api/public/base/enum_set.h

Issue 809073005: replace COMPILE_ASSERT with static_assert in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit Created 5 years, 11 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 | « sync/api/string_ordinal.h ('k') | sync/internal_api/public/base/node_ordinal.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 SYNC_INTERNAL_API_PUBLIC_BASE_ENUM_SET_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_ENUM_SET_H_
6 #define SYNC_INTERNAL_API_PUBLIC_BASE_ENUM_SET_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_ENUM_SET_H_
7 7
8 #include <bitset> 8 #include <bitset>
9 #include <cstddef> 9 #include <cstddef>
10 #include <string> 10 #include <string>
(...skipping 28 matching lines...) Expand all
39 // (say, fewer than 64), you can efficiently pass around an EnumSet 39 // (say, fewer than 64), you can efficiently pass around an EnumSet
40 // for that enum around by value. 40 // for that enum around by value.
41 41
42 template <typename E, E MinEnumValue, E MaxEnumValue> 42 template <typename E, E MinEnumValue, E MaxEnumValue>
43 class EnumSet { 43 class EnumSet {
44 public: 44 public:
45 typedef E EnumType; 45 typedef E EnumType;
46 static const E kMinValue = MinEnumValue; 46 static const E kMinValue = MinEnumValue;
47 static const E kMaxValue = MaxEnumValue; 47 static const E kMaxValue = MaxEnumValue;
48 static const size_t kValueCount = kMaxValue - kMinValue + 1; 48 static const size_t kValueCount = kMaxValue - kMinValue + 1;
49 COMPILE_ASSERT(kMinValue < kMaxValue, 49 static_assert(kMinValue < kMaxValue,
50 min_value_must_be_less_than_max_value); 50 "min value must be less than max value");
51 51
52 private: 52 private:
53 // Declaration needed by Iterator. 53 // Declaration needed by Iterator.
54 typedef std::bitset<kValueCount> EnumBitSet; 54 typedef std::bitset<kValueCount> EnumBitSet;
55 55
56 public: 56 public:
57 // Iterator is a forward-only read-only iterator for EnumSet. Its 57 // Iterator is a forward-only read-only iterator for EnumSet. Its
58 // interface is deliberately distinct from an STL iterator as its 58 // interface is deliberately distinct from an STL iterator as its
59 // semantics are substantially different. 59 // semantics are substantially different.
60 // 60 //
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 template <typename E, E Min, E Max> 277 template <typename E, E Min, E Max>
278 EnumSet<E, Min, Max> Difference(EnumSet<E, Min, Max> set1, 278 EnumSet<E, Min, Max> Difference(EnumSet<E, Min, Max> set1,
279 EnumSet<E, Min, Max> set2) { 279 EnumSet<E, Min, Max> set2) {
280 return EnumSet<E, Min, Max>(set1.enums_ & ~set2.enums_); 280 return EnumSet<E, Min, Max>(set1.enums_ & ~set2.enums_);
281 } 281 }
282 282
283 } // namespace syncer 283 } // namespace syncer
284 284
285 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_ENUM_SET_H_ 285 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_ENUM_SET_H_
OLDNEW
« no previous file with comments | « sync/api/string_ordinal.h ('k') | sync/internal_api/public/base/node_ordinal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698