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

Side by Side Diff: base/memory/scoped_ptr.h

Issue 1763983002: Change scoped_ptr to a type alias for std::unique_ptr on OS_WIN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bluetooth Created 4 years, 9 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 | « no previous file | base/memory/scoped_ptr_unittest.cc » ('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 // Scopers help you manage ownership of a pointer, helping you easily manage a 5 // Scopers help you manage ownership of a pointer, helping you easily manage a
6 // pointer within a scope, and automatically destroying the pointer at the end 6 // pointer within a scope, and automatically destroying the pointer at the end
7 // of a scope. There are two main classes you will use, which correspond to the 7 // of a scope. There are two main classes you will use, which correspond to the
8 // operators new/delete and new[]/delete[]. 8 // operators new/delete and new[]/delete[].
9 // 9 //
10 // Example usage (scoped_ptr<T>): 10 // Example usage (scoped_ptr<T>):
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 inline void operator()(void* ptr) const { 116 inline void operator()(void* ptr) const {
117 free(ptr); 117 free(ptr);
118 } 118 }
119 }; 119 };
120 120
121 } // namespace base 121 } // namespace base
122 122
123 // Now that scoped_ptr is almost 100% compatible with std::unique_ptr, we're 123 // Now that scoped_ptr is almost 100% compatible with std::unique_ptr, we're
124 // incrementally migrating scoped_ptr to just be a type alias for 124 // incrementally migrating scoped_ptr to just be a type alias for
125 // std::unique_ptr. The eventual goal is to delete scoped_ptr altogether. 125 // std::unique_ptr. The eventual goal is to delete scoped_ptr altogether.
126 #if defined(OS_LINUX) 126 #if defined(OS_LINUX) || defined(OS_WIN)
127 template <typename T, typename D = std::default_delete<T>> 127 template <typename T, typename D = std::default_delete<T>>
128 using scoped_ptr = std::unique_ptr<T, D>; 128 using scoped_ptr = std::unique_ptr<T, D>;
129 129
130 // Versions of libstdc++ 4.8 lack overloads for <, <=, >, and >= when comparing 130 // Versions of libstdc++ 4.8 lack overloads for <, <=, >, and >= when comparing
131 // a std::unique_ptr and nullptr_t. 131 // a std::unique_ptr and nullptr_t.
132 #if defined(__GLIBCXX__) && __GLIBCXX__ < 20150426 132 #if defined(__GLIBCXX__) && __GLIBCXX__ < 20150426
133 template <class T, class D> 133 template <class T, class D>
134 bool operator<(const scoped_ptr<T, D>& p, std::nullptr_t) { 134 bool operator<(const scoped_ptr<T, D>& p, std::nullptr_t) {
135 return p.get() < nullptr; 135 return p.get() < nullptr;
136 } 136 }
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 671
672 // A function to convert T* into scoped_ptr<T> 672 // A function to convert T* into scoped_ptr<T>
673 // Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation 673 // Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
674 // for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg)) 674 // for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
675 template <typename T> 675 template <typename T>
676 scoped_ptr<T> make_scoped_ptr(T* ptr) { 676 scoped_ptr<T> make_scoped_ptr(T* ptr) {
677 return scoped_ptr<T>(ptr); 677 return scoped_ptr<T>(ptr);
678 } 678 }
679 679
680 #endif // BASE_MEMORY_SCOPED_PTR_H_ 680 #endif // BASE_MEMORY_SCOPED_PTR_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/scoped_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698