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 // 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #ifndef BASE_MEMORY_SCOPED_PTR_H_ | 77 #ifndef BASE_MEMORY_SCOPED_PTR_H_ |
78 #define BASE_MEMORY_SCOPED_PTR_H_ | 78 #define BASE_MEMORY_SCOPED_PTR_H_ |
79 | 79 |
80 // This is an implementation designed to match the anticipated future TR2 | 80 // This is an implementation designed to match the anticipated future TR2 |
81 // implementation of the scoped_ptr class. | 81 // implementation of the scoped_ptr class. |
82 | 82 |
83 #include <assert.h> | 83 #include <assert.h> |
84 #include <stddef.h> | 84 #include <stddef.h> |
85 #include <stdlib.h> | 85 #include <stdlib.h> |
86 | 86 |
87 // TODO(dcheng): Temporary, remove this #include since swap is defined in | |
88 // <utility> in C++11. | |
89 #include <algorithm> | |
90 #include <iosfwd> | 87 #include <iosfwd> |
91 #include <memory> | 88 #include <memory> |
92 #include <utility> | 89 #include <utility> |
93 | 90 |
94 #include "base/basictypes.h" | 91 #include "base/basictypes.h" |
95 #include "base/compiler_specific.h" | 92 #include "base/compiler_specific.h" |
96 #include "base/move.h" | 93 #include "base/move.h" |
97 #include "base/template_util.h" | 94 #include "base/template_util.h" |
98 | 95 |
99 namespace base { | 96 namespace base { |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 scoped_ptr<T> make_scoped_ptr(T* ptr) { | 551 scoped_ptr<T> make_scoped_ptr(T* ptr) { |
555 return scoped_ptr<T>(ptr); | 552 return scoped_ptr<T>(ptr); |
556 } | 553 } |
557 | 554 |
558 template <typename T> | 555 template <typename T> |
559 std::ostream& operator<<(std::ostream& out, const scoped_ptr<T>& p) { | 556 std::ostream& operator<<(std::ostream& out, const scoped_ptr<T>& p) { |
560 return out << p.get(); | 557 return out << p.get(); |
561 } | 558 } |
562 | 559 |
563 #endif // BASE_MEMORY_SCOPED_PTR_H_ | 560 #endif // BASE_MEMORY_SCOPED_PTR_H_ |
OLD | NEW |