Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/intrusive_ptr.h

Issue 29713594: #Too long, see below (Closed) Base URL: github.com:adblockplus/adblockpluscore
Patch Set: Created March 2, 2018, 3:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 virtual ~ref_counted() 58 virtual ~ref_counted()
59 { 59 {
60 assert2(mRefCount == 0, u"Destroying a ref-counted object with a non-zero re ference count"_str); 60 assert2(mRefCount == 0, u"Destroying a ref-counted object with a non-zero re ference count"_str);
61 } 61 }
62 62
63 private: 63 private:
64 int mRefCount; 64 int mRefCount;
65 }; 65 };
66 66
67 template<typename T, 67 template<typename T>
68 class = typename std::enable_if<std::is_base_of<ref_counted,T>::value>::type >
69 class intrusive_ptr 68 class intrusive_ptr
70 { 69 {
70 static_assert(std::is_base_of<ref_counted, T>::value, "The class T should inhe rit ref_counted");
71 public: 71 public:
72 explicit intrusive_ptr() 72 explicit intrusive_ptr()
73 : mPointer(nullptr) 73 : mPointer(nullptr)
74 { 74 {
75 } 75 }
76 76
77 explicit intrusive_ptr(T* pointer, bool addRef = true) 77 explicit intrusive_ptr(T* pointer, bool addRef = true)
78 : mPointer(pointer) 78 : mPointer(pointer)
79 { 79 {
80 if (mPointer && addRef) 80 if (mPointer && addRef)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return a == b.get(); 216 return a == b.get();
217 } 217 }
218 218
219 template<typename T, typename U> 219 template<typename T, typename U>
220 inline bool operator!=(const T* a, intrusive_ptr<U> const& b) 220 inline bool operator!=(const T* a, intrusive_ptr<U> const& b)
221 { 221 {
222 return a != b.get(); 222 return a != b.get();
223 } 223 }
224 224
225 ABP_NS_END 225 ABP_NS_END
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld