OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_COMMON_PERMISSIONS_BASE_SET_OPERATORS_H_ | 5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_BASE_SET_OPERATORS_H_ |
6 #define EXTENSIONS_COMMON_PERMISSIONS_BASE_SET_OPERATORS_H_ | 6 #define EXTENSIONS_COMMON_PERMISSIONS_BASE_SET_OPERATORS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <iterator> | 10 #include <iterator> |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/template_util.h" | |
15 | 14 |
16 namespace extensions { | 15 namespace extensions { |
17 | 16 |
18 // Traits for template paramater of |BaseSetOperators<T>|. Specializations | 17 // Traits for template paramater of |BaseSetOperators<T>|. Specializations |
19 // should define |ElementType| for the type of elements to store in the set, | 18 // should define |ElementType| for the type of elements to store in the set, |
20 // and |EmementIDType| for the type of element identifiers. | 19 // and |EmementIDType| for the type of element identifiers. |
21 template <typename T> | 20 template <typename T> |
22 struct BaseSetOperatorsTraits {}; | 21 struct BaseSetOperatorsTraits {}; |
23 | 22 |
24 // Set operations shared by |APIPermissionSet| and |ManifestPermissionSet|. | 23 // Set operations shared by |APIPermissionSet| and |ManifestPermissionSet|. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return it_->second.get(); | 63 return it_->second.get(); |
65 } | 64 } |
66 | 65 |
67 private: | 66 private: |
68 typename Map::const_iterator it_; | 67 typename Map::const_iterator it_; |
69 }; | 68 }; |
70 | 69 |
71 BaseSetOperators() { | 70 BaseSetOperators() { |
72 // Ensure |T| is convertible to us, so we can safely downcast when calling | 71 // Ensure |T| is convertible to us, so we can safely downcast when calling |
73 // methods that must exist in |T|. | 72 // methods that must exist in |T|. |
74 static_assert((base::is_convertible<T*, BaseSetOperators<T>*>::value), | 73 static_assert(std::is_convertible<T*, BaseSetOperators<T>*>::value, |
75 "U ptr must implicitly convert to T ptr"); | 74 "U ptr must implicitly convert to T ptr"); |
76 } | 75 } |
77 | 76 |
78 BaseSetOperators(const T& set) { | 77 BaseSetOperators(const T& set) { |
79 this->operator=(set); | 78 this->operator=(set); |
80 } | 79 } |
81 | 80 |
82 ~BaseSetOperators() {} | 81 ~BaseSetOperators() {} |
83 | 82 |
84 T& operator=(const T& rhs) { | 83 T& operator=(const T& rhs) { |
85 return Assign(rhs); | 84 return Assign(rhs); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 map_.clear(); | 280 map_.clear(); |
282 } | 281 } |
283 | 282 |
284 private: | 283 private: |
285 Map map_; | 284 Map map_; |
286 }; | 285 }; |
287 | 286 |
288 } // namespace extensions | 287 } // namespace extensions |
289 | 288 |
290 #endif // EXTENSIONS_COMMON_PERMISSIONS_BASE_SET_OPERATORS_H_ | 289 #endif // EXTENSIONS_COMMON_PERMISSIONS_BASE_SET_OPERATORS_H_ |
OLD | NEW |