| OLD | NEW |
| 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 COMPONENTS_SYNC_BASE_ENUM_SET_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_ENUM_SET_H_ |
| 6 #define COMPONENTS_SYNC_BASE_ENUM_SET_H_ | 6 #define COMPONENTS_SYNC_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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // /* ERROR */ | 70 // /* ERROR */ |
| 71 // for (EnumSet<...>::Iterator it = SomeFun().First(); ... | 71 // for (EnumSet<...>::Iterator it = SomeFun().First(); ... |
| 72 // | 72 // |
| 73 // Also, there are no guarantees as to what will happen if you | 73 // Also, there are no guarantees as to what will happen if you |
| 74 // modify an EnumSet while traversing it with an iterator. | 74 // modify an EnumSet while traversing it with an iterator. |
| 75 class Iterator { | 75 class Iterator { |
| 76 public: | 76 public: |
| 77 // A default-constructed iterator can't do anything except check | 77 // A default-constructed iterator can't do anything except check |
| 78 // Good(). You need to call First() on an EnumSet to get a usable | 78 // Good(). You need to call First() on an EnumSet to get a usable |
| 79 // iterator. | 79 // iterator. |
| 80 Iterator() : enums_(NULL), i_(kValueCount) {} | 80 Iterator() : enums_(nullptr), i_(kValueCount) {} |
| 81 ~Iterator() {} | 81 ~Iterator() {} |
| 82 | 82 |
| 83 // Copy constructor and assignment welcome. | 83 // Copy constructor and assignment welcome. |
| 84 | 84 |
| 85 // Returns true iff the iterator points to an EnumSet and it | 85 // Returns true iff the iterator points to an EnumSet and it |
| 86 // hasn't yet traversed the EnumSet entirely. | 86 // hasn't yet traversed the EnumSet entirely. |
| 87 bool Good() const { return enums_ && i_ < kValueCount && enums_->test(i_); } | 87 bool Good() const { return enums_ && i_ < kValueCount && enums_->test(i_); } |
| 88 | 88 |
| 89 // Returns the value the iterator currently points to. Good() | 89 // Returns the value the iterator currently points to. Good() |
| 90 // must hold. | 90 // must hold. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 template <typename E, E Min, E Max> | 255 template <typename E, E Min, E Max> |
| 256 EnumSet<E, Min, Max> Difference(EnumSet<E, Min, Max> set1, | 256 EnumSet<E, Min, Max> Difference(EnumSet<E, Min, Max> set1, |
| 257 EnumSet<E, Min, Max> set2) { | 257 EnumSet<E, Min, Max> set2) { |
| 258 return EnumSet<E, Min, Max>(set1.enums_ & ~set2.enums_); | 258 return EnumSet<E, Min, Max>(set1.enums_ & ~set2.enums_); |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace syncer | 261 } // namespace syncer |
| 262 | 262 |
| 263 #endif // COMPONENTS_SYNC_BASE_ENUM_SET_H_ | 263 #endif // COMPONENTS_SYNC_BASE_ENUM_SET_H_ |
| OLD | NEW |