Prevent multiple pending UpdatePolicy tasks.
[chromium-blink-merge.git] / tools / clang / rewrite_scoped_refptr / tests / scoped_refptr.h
blob1ebd323358b650ecef338a18ae3013407ee9d9f5
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*.
9 template <class T>
10 class scoped_refptr {
11 public:
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_) {}
17 template <typename U>
18 scoped_refptr(const scoped_refptr<U>& r)
19 : ptr_(r.get()) {}
21 ~scoped_refptr() {}
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) {
28 ptr_ = p;
29 return *this;
31 scoped_refptr<T>& operator=(const scoped_refptr<T>& r) {
32 return *this = r.ptr_;
34 template <typename U>
35 scoped_refptr<T>& operator=(const scoped_refptr<U>& r) {
36 return *this = r.get();
39 protected:
40 T* ptr_;
43 #endif // SCOPED_REFPTR_H_