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

Side by Side Diff: base/stl_util.h

Issue 2565913002: [Onion Soup] Move WebBluetoothImpl from //content/renderer/bluetooth to Blink's bluetooth module (Closed)
Patch Set: check if binding is bound before close it Created 4 years 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
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 // Derived from google3/util/gtl/stl_util.h 5 // Derived from google3/util/gtl/stl_util.h
6 6
7 #ifndef BASE_STL_UTIL_H_ 7 #ifndef BASE_STL_UTIL_H_
8 #define BASE_STL_UTIL_H_ 8 #define BASE_STL_UTIL_H_
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <functional> 11 #include <functional>
12 #include <iterator> 12 #include <iterator>
13 #include <memory>
13 #include <string> 14 #include <string>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/logging.h" 17 #include "base/logging.h"
17 18
18 namespace base { 19 namespace base {
19 20
20 // Clears internal memory of an STL object. 21 // Clears internal memory of an STL object.
21 // STL clear()/reserve(0) does not always free internal memory allocated 22 // STL clear()/reserve(0) does not always free internal memory allocated
22 // This function uses swap/destructor to ensure the internal memory is freed. 23 // This function uses swap/destructor to ensure the internal memory is freed.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Returns true if the sorted container |a1| contains all elements of the sorted 120 // Returns true if the sorted container |a1| contains all elements of the sorted
120 // container |a2|. 121 // container |a2|.
121 template <typename Arg1, typename Arg2> 122 template <typename Arg1, typename Arg2>
122 bool STLIncludes(const Arg1& a1, const Arg2& a2) { 123 bool STLIncludes(const Arg1& a1, const Arg2& a2) {
123 DCHECK(STLIsSorted(a1)); 124 DCHECK(STLIsSorted(a1));
124 DCHECK(STLIsSorted(a2)); 125 DCHECK(STLIsSorted(a2));
125 return std::includes(a1.begin(), a1.end(), 126 return std::includes(a1.begin(), a1.end(),
126 a2.begin(), a2.end()); 127 a2.begin(), a2.end());
127 } 128 }
128 129
130 // Means of generating a key for searching STL collections of std::unique_ptr
131 // that avoids the side effect of deleting the pointer.
132 template <class T>
133 class FakeUniquePtr : public std::unique_ptr<T> {
134 public:
135 using std::unique_ptr<T>::unique_ptr;
136 ~FakeUniquePtr() { std::unique_ptr<T>::release(); }
137 };
138
129 } // namespace base 139 } // namespace base
130 140
131 #endif // BASE_STL_UTIL_H_ 141 #endif // BASE_STL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698