OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good | 291 // empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good |
292 // discussion of this technique. | 292 // discussion of this technique. |
293 struct Data : public D { | 293 struct Data : public D { |
294 explicit Data(T* ptr_in) : ptr(ptr_in) {} | 294 explicit Data(T* ptr_in) : ptr(ptr_in) {} |
295 Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {} | 295 Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {} |
296 T* ptr; | 296 T* ptr; |
297 }; | 297 }; |
298 | 298 |
299 Data data_; | 299 Data data_; |
300 | 300 |
301 DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl); | 301 RTC_DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl); |
302 }; | 302 }; |
303 | 303 |
304 } // namespace internal | 304 } // namespace internal |
305 | 305 |
306 // A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T> | 306 // A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T> |
307 // automatically deletes the pointer it holds (if any). | 307 // automatically deletes the pointer it holds (if any). |
308 // That is, scoped_ptr<T> owns the T object that it points to. | 308 // That is, scoped_ptr<T> owns the T object that it points to. |
309 // Like a T*, a scoped_ptr<T> may hold either nullptr or a pointer to a T | 309 // Like a T*, a scoped_ptr<T> may hold either nullptr or a pointer to a T |
310 // object. Also like T*, scoped_ptr<T> is thread-compatible, and once you | 310 // object. Also like T*, scoped_ptr<T> is thread-compatible, and once you |
311 // dereference it, you get the thread safety guarantees of T. | 311 // dereference it, you get the thread safety guarantees of T. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 627 |
628 // A function to convert T* into scoped_ptr<T> | 628 // A function to convert T* into scoped_ptr<T> |
629 // Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation | 629 // Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation |
630 // for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg)) | 630 // for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg)) |
631 template <typename T> | 631 template <typename T> |
632 rtc::scoped_ptr<T> rtc_make_scoped_ptr(T* ptr) { | 632 rtc::scoped_ptr<T> rtc_make_scoped_ptr(T* ptr) { |
633 return rtc::scoped_ptr<T>(ptr); | 633 return rtc::scoped_ptr<T>(ptr); |
634 } | 634 } |
635 | 635 |
636 #endif // #ifndef WEBRTC_BASE_SCOPED_PTR_H__ | 636 #endif // #ifndef WEBRTC_BASE_SCOPED_PTR_H__ |
OLD | NEW |