OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 namespace WTF { | 44 namespace WTF { |
45 | 45 |
46 template<typename T> | 46 template<typename T> |
47 class RawPtr { | 47 class RawPtr { |
48 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(RawPtr); | 48 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(RawPtr); |
49 WTF_DISALLOW_ZERO_ASSIGNMENT(RawPtr); | 49 WTF_DISALLOW_ZERO_ASSIGNMENT(RawPtr); |
50 public: | 50 public: |
51 RawPtr() : m_ptr(0) { } | 51 RawPtr() : m_ptr(0) { } |
52 RawPtr(std::nullptr_t) : m_ptr(0) { } | 52 RawPtr(std::nullptr_t) : m_ptr(0) { } |
53 RawPtr(T* ptr) : m_ptr(ptr) { } | 53 RawPtr(T* ptr) : m_ptr(ptr) { } |
54 RawPtr(T& reference) : m_ptr(&reference) { } | |
Mikhail
2014/03/05 06:33:43
Shouldn't it be explicit? (to prevent from acciden
| |
54 RawPtr(const RawPtr& other) | 55 RawPtr(const RawPtr& other) |
55 : m_ptr(other.get()) | 56 : m_ptr(other.get()) |
56 { | 57 { |
57 } | 58 } |
58 | 59 |
59 template<typename U> | 60 template<typename U> |
60 RawPtr(const RawPtr<U>& other) | 61 RawPtr(const RawPtr<U>& other) |
61 : m_ptr(other.get()) | 62 : m_ptr(other.get()) |
62 { | 63 { |
63 } | 64 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 template<typename T> inline T* getPtr(const RawPtr<T>& p) | 127 template<typename T> inline T* getPtr(const RawPtr<T>& p) |
127 { | 128 { |
128 return p.get(); | 129 return p.get(); |
129 } | 130 } |
130 | 131 |
131 } // namespace WTF | 132 } // namespace WTF |
132 | 133 |
133 using WTF::RawPtr; | 134 using WTF::RawPtr; |
134 | 135 |
135 #endif | 136 #endif |
OLD | NEW |