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

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

Issue 1501793003: Rename MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move-name: todos Created 5 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
« no previous file with comments | « PRESUBMIT_test.py ('k') | base/move.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 // 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // std::default_delete, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters 231 // std::default_delete, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters
232 // will increase the size proportional to whatever state they need to have. See 232 // will increase the size proportional to whatever state they need to have. See
233 // comments inside scoped_ptr_impl<> for details. 233 // comments inside scoped_ptr_impl<> for details.
234 // 234 //
235 // Current implementation targets having a strict subset of C++11's 235 // Current implementation targets having a strict subset of C++11's
236 // unique_ptr<> features. Known deficiencies include not supporting move-only 236 // unique_ptr<> features. Known deficiencies include not supporting move-only
237 // deleteres, function pointers as deleters, and deleters with reference 237 // deleteres, function pointers as deleters, and deleters with reference
238 // types. 238 // types.
239 template <class T, class D = std::default_delete<T>> 239 template <class T, class D = std::default_delete<T>>
240 class scoped_ptr { 240 class scoped_ptr {
241 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(scoped_ptr) 241 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(scoped_ptr)
242 242
243 static_assert(base::internal::IsNotRefCounted<T>::value, 243 static_assert(base::internal::IsNotRefCounted<T>::value,
244 "T is a refcounted type and needs a scoped_refptr"); 244 "T is a refcounted type and needs a scoped_refptr");
245 245
246 public: 246 public:
247 // The element and deleter types. 247 // The element and deleter types.
248 using element_type = T; 248 using element_type = T;
249 using deleter_type = D; 249 using deleter_type = D;
250 250
251 // Constructor. Defaults to initializing with nullptr. 251 // Constructor. Defaults to initializing with nullptr.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // Needed to reach into |impl_| in the constructor. 396 // Needed to reach into |impl_| in the constructor.
397 template <typename U, typename V> friend class scoped_ptr; 397 template <typename U, typename V> friend class scoped_ptr;
398 base::internal::scoped_ptr_impl<element_type, deleter_type> impl_; 398 base::internal::scoped_ptr_impl<element_type, deleter_type> impl_;
399 399
400 // Forbidden for API compatibility with std::unique_ptr. 400 // Forbidden for API compatibility with std::unique_ptr.
401 explicit scoped_ptr(int disallow_construction_from_null); 401 explicit scoped_ptr(int disallow_construction_from_null);
402 }; 402 };
403 403
404 template <class T, class D> 404 template <class T, class D>
405 class scoped_ptr<T[], D> { 405 class scoped_ptr<T[], D> {
406 MOVE_ONLY_TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(scoped_ptr) 406 DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(scoped_ptr)
407 407
408 public: 408 public:
409 // The element and deleter types. 409 // The element and deleter types.
410 using element_type = T; 410 using element_type = T;
411 using deleter_type = D; 411 using deleter_type = D;
412 412
413 // Constructor. Defaults to initializing with nullptr. 413 // Constructor. Defaults to initializing with nullptr.
414 scoped_ptr() : impl_(nullptr) {} 414 scoped_ptr() : impl_(nullptr) {}
415 415
416 // Constructor. Stores the given array. Note that the argument's type 416 // Constructor. Stores the given array. Note that the argument's type
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 scoped_ptr<T> make_scoped_ptr(T* ptr) { 596 scoped_ptr<T> make_scoped_ptr(T* ptr) {
597 return scoped_ptr<T>(ptr); 597 return scoped_ptr<T>(ptr);
598 } 598 }
599 599
600 template <typename T> 600 template <typename T>
601 std::ostream& operator<<(std::ostream& out, const scoped_ptr<T>& p) { 601 std::ostream& operator<<(std::ostream& out, const scoped_ptr<T>& p) {
602 return out << p.get(); 602 return out << p.get();
603 } 603 }
604 604
605 #endif // BASE_MEMORY_SCOPED_PTR_H_ 605 #endif // BASE_MEMORY_SCOPED_PTR_H_
OLDNEW
« no previous file with comments | « PRESUBMIT_test.py ('k') | base/move.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698