1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SCOPED_REFPTR_H_
6 #define SCOPED_REFPTR_H_
8 // Stub scoped_refptr<T> class that supports an implicit cast to T*.
12 typedef T element_type;
13 scoped_refptr() : ptr_(0) {}
14 scoped_refptr(T* p) : ptr_(p) {}
15 scoped_refptr(const scoped_refptr<T>& r) : ptr_(r.ptr_) {}
18 scoped_refptr(const scoped_refptr<U>& r)
23 T* get() const { return ptr_; }
24 operator T*() const { return ptr_; }
25 T* operator->() const { return ptr_; }
27 scoped_refptr<T>& operator=(T* p) {
31 scoped_refptr<T>& operator=(const scoped_refptr<T>& r) {
32 return *this = r.ptr_;
35 scoped_refptr<T>& operator=(const scoped_refptr<U>& r) {
36 return *this = r.get();
43 #endif // SCOPED_REFPTR_H_