/src/icu/source/common/unicode/localpointer.h
Line | Count | Source (jump to first uncovered line) |
1 | | // © 2016 and later: Unicode, Inc. and others. |
2 | | // License & terms of use: http://www.unicode.org/copyright.html |
3 | | /* |
4 | | ******************************************************************************* |
5 | | * |
6 | | * Copyright (C) 2009-2016, International Business Machines |
7 | | * Corporation and others. All Rights Reserved. |
8 | | * |
9 | | ******************************************************************************* |
10 | | * file name: localpointer.h |
11 | | * encoding: UTF-8 |
12 | | * tab size: 8 (not used) |
13 | | * indentation:4 |
14 | | * |
15 | | * created on: 2009nov13 |
16 | | * created by: Markus W. Scherer |
17 | | */ |
18 | | |
19 | | #ifndef __LOCALPOINTER_H__ |
20 | | #define __LOCALPOINTER_H__ |
21 | | |
22 | | /** |
23 | | * \file |
24 | | * \brief C++ API: "Smart pointers" for use with and in ICU4C C++ code. |
25 | | * |
26 | | * These classes are inspired by |
27 | | * - std::auto_ptr |
28 | | * - boost::scoped_ptr & boost::scoped_array |
29 | | * - Taligent Safe Pointers (TOnlyPointerTo) |
30 | | * |
31 | | * but none of those provide for all of the goals for ICU smart pointers: |
32 | | * - Smart pointer owns the object and releases it when it goes out of scope. |
33 | | * - No transfer of ownership via copy/assignment to reduce misuse. Simpler & more robust. |
34 | | * - ICU-compatible: No exceptions. |
35 | | * - Need to be able to orphan/release the pointer and its ownership. |
36 | | * - Need variants for normal C++ object pointers, C++ arrays, and ICU C service objects. |
37 | | * |
38 | | * For details see https://icu.unicode.org/design/cpp/scoped_ptr |
39 | | */ |
40 | | |
41 | | #include "unicode/utypes.h" |
42 | | |
43 | | #if U_SHOW_CPLUSPLUS_API |
44 | | |
45 | | #include <memory> |
46 | | |
47 | | U_NAMESPACE_BEGIN |
48 | | |
49 | | /** |
50 | | * "Smart pointer" base class; do not use directly: use LocalPointer etc. |
51 | | * |
52 | | * Base class for smart pointer classes that do not throw exceptions. |
53 | | * |
54 | | * Do not use this base class directly, since it does not delete its pointer. |
55 | | * A subclass must implement methods that delete the pointer: |
56 | | * Destructor and adoptInstead(). |
57 | | * |
58 | | * There is no operator T *() provided because the programmer must decide |
59 | | * whether to use getAlias() (without transfer of ownership) or orphan() |
60 | | * (with transfer of ownership and NULLing of the pointer). |
61 | | * |
62 | | * @see LocalPointer |
63 | | * @see LocalArray |
64 | | * @see U_DEFINE_LOCAL_OPEN_POINTER |
65 | | * @stable ICU 4.4 |
66 | | */ |
67 | | template<typename T> |
68 | | class LocalPointerBase { |
69 | | public: |
70 | | // No heap allocation. Use only on the stack. |
71 | | static void* U_EXPORT2 operator new(size_t) = delete; |
72 | | static void* U_EXPORT2 operator new[](size_t) = delete; |
73 | | #if U_HAVE_PLACEMENT_NEW |
74 | | static void* U_EXPORT2 operator new(size_t, void*) = delete; |
75 | | #endif |
76 | | |
77 | | /** |
78 | | * Constructor takes ownership. |
79 | | * @param p simple pointer to an object that is adopted |
80 | | * @stable ICU 4.4 |
81 | | */ |
82 | 0 | explicit LocalPointerBase(T *p=NULL) : ptr(p) {} Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::LocalPointerBase(icu_71::CollationTailoring*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeSet>::LocalPointerBase(icu_71::UnicodeSet*) Unexecuted instantiation: icu_71::LocalPointerBase<unsigned char>::LocalPointerBase(unsigned char*) Unexecuted instantiation: icu_71::LocalPointerBase<UResourceBundle>::LocalPointerBase(UResourceBundle*) Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::LocalPointerBase(UEnumeration*) Unexecuted instantiation: icu_71::LocalPointerBase<char const*>::LocalPointerBase(char const**) Unexecuted instantiation: icu_71::LocalPointerBase<int>::LocalPointerBase(int*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CharString>::LocalPointerBase(icu_71::CharString*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::StringEnumeration>::LocalPointerBase(icu_71::StringEnumeration*) Unexecuted instantiation: icu_71::LocalPointerBase<UHashtable>::LocalPointerBase(UHashtable*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UVector>::LocalPointerBase(icu_71::UVector*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UObject>::LocalPointerBase(icu_71::UObject*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeString>::LocalPointerBase(icu_71::UnicodeString*) Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::ICUServiceFactory>::LocalPointerBase(icu_71::ICUServiceFactory*) Unexecuted instantiation: icu_71::LocalPointerBase<UKeywordsContext>::LocalPointerBase(UKeywordsContext*) Unexecuted instantiation: icu_71::LocalPointerBase<ULanguageTag>::LocalPointerBase(ULanguageTag*) Unexecuted instantiation: umutablecptrie.cpp:icu_71::LocalPointerBase<icu_71::(anonymous namespace)::MutableCodePointTrie>::LocalPointerBase(icu_71::(anonymous namespace)::MutableCodePointTrie*) |
83 | | /** |
84 | | * Destructor deletes the object it owns. |
85 | | * Subclass must override: Base class does nothing. |
86 | | * @stable ICU 4.4 |
87 | | */ |
88 | 0 | ~LocalPointerBase() { /* delete ptr; */ } Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeSet>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<unsigned char>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<UResourceBundle>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<int>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<char const*>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CharString>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::StringEnumeration>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<UHashtable>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UVector>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UObject>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeString>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::ICUServiceFactory>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<UKeywordsContext>::~LocalPointerBase() Unexecuted instantiation: icu_71::LocalPointerBase<ULanguageTag>::~LocalPointerBase() Unexecuted instantiation: umutablecptrie.cpp:icu_71::LocalPointerBase<icu_71::(anonymous namespace)::MutableCodePointTrie>::~LocalPointerBase() |
89 | | /** |
90 | | * NULL check. |
91 | | * @return true if ==NULL |
92 | | * @stable ICU 4.4 |
93 | | */ |
94 | 0 | UBool isNull() const { return ptr==NULL; } Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<unsigned char>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CharString>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::StringEnumeration>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UVector>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<UKeywordsContext>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::isNull() const Unexecuted instantiation: icu_71::LocalPointerBase<ULanguageTag>::isNull() const |
95 | | /** |
96 | | * NULL check. |
97 | | * @return true if !=NULL |
98 | | * @stable ICU 4.4 |
99 | | */ |
100 | 0 | UBool isValid() const { return ptr!=NULL; } Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UObject>::isValid() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UVector>::isValid() const Unexecuted instantiation: icu_71::LocalPointerBase<UResourceBundle>::isValid() const Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::isValid() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeString>::isValid() const |
101 | | /** |
102 | | * Comparison with a simple pointer, so that existing code |
103 | | * with ==NULL need not be changed. |
104 | | * @param other simple pointer for comparison |
105 | | * @return true if this pointer value equals other |
106 | | * @stable ICU 4.4 |
107 | | */ |
108 | | bool operator==(const T *other) const { return ptr==other; } |
109 | | /** |
110 | | * Comparison with a simple pointer, so that existing code |
111 | | * with !=NULL need not be changed. |
112 | | * @param other simple pointer for comparison |
113 | | * @return true if this pointer value differs from other |
114 | | * @stable ICU 4.4 |
115 | | */ |
116 | | bool operator!=(const T *other) const { return ptr!=other; } |
117 | | /** |
118 | | * Access without ownership change. |
119 | | * @return the pointer value |
120 | | * @stable ICU 4.4 |
121 | | */ |
122 | 0 | T *getAlias() const { return ptr; } Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<unsigned char>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<UResourceBundle>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<UHashtable>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::StringEnumeration>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeSet>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UObject>::getAlias() const Unexecuted instantiation: icu_71::LocalPointerBase<ULanguageTag>::getAlias() const |
123 | | /** |
124 | | * Access without ownership change. |
125 | | * @return the pointer value as a reference |
126 | | * @stable ICU 4.4 |
127 | | */ |
128 | 0 | T &operator*() const { return *ptr; } Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::operator*() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeSet>::operator*() const |
129 | | /** |
130 | | * Access without ownership change. |
131 | | * @return the pointer value |
132 | | * @stable ICU 4.4 |
133 | | */ |
134 | 0 | T *operator->() const { return ptr; } Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CharString>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::StringEnumeration>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeString>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UVector>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<UKeywordsContext>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<ULanguageTag>::operator->() const Unexecuted instantiation: umutablecptrie.cpp:icu_71::LocalPointerBase<icu_71::(anonymous namespace)::MutableCodePointTrie>::operator->() const Unexecuted instantiation: icu_71::LocalPointerBase<UResourceBundle>::operator->() const |
135 | | /** |
136 | | * Gives up ownership; the internal pointer becomes NULL. |
137 | | * @return the pointer value; |
138 | | * caller becomes responsible for deleting the object |
139 | | * @stable ICU 4.4 |
140 | | */ |
141 | 0 | T *orphan() { |
142 | 0 | T *p=ptr; |
143 | 0 | ptr=NULL; |
144 | 0 | return p; |
145 | 0 | } Unexecuted instantiation: icu_71::LocalPointerBase<USet>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UNormalizer2>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UEnumeration>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UCollator>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UCPTrie>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UHashtable>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UResourceBundle>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UDataMemory>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CollationTailoring>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<unsigned char>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UText>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UBreakIterator>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::CharString>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeSet>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UMutableCPTrie>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UObject>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UnicodeString>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::UVector>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<icu_71::ICUServiceFactory>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UCaseMap>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UConverter>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<UKeywordsContext>::orphan() Unexecuted instantiation: icu_71::LocalPointerBase<ULanguageTag>::orphan() Unexecuted instantiation: umutablecptrie.cpp:icu_71::LocalPointerBase<icu_71::(anonymous namespace)::MutableCodePointTrie>::orphan() |
146 | | /** |
147 | | * Deletes the object it owns, |
148 | | * and adopts (takes ownership of) the one passed in. |
149 | | * Subclass must override: Base class does not delete the object. |
150 | | * @param p simple pointer to an object that is adopted |
151 | | * @stable ICU 4.4 |
152 | | */ |
153 | | void adoptInstead(T *p) { |
154 | | // delete ptr; |
155 | | ptr=p; |
156 | | } |
157 | | protected: |
158 | | /** |
159 | | * Actual pointer. |
160 | | * @internal |
161 | | */ |
162 | | T *ptr; |
163 | | private: |
164 | | // No comparison operators with other LocalPointerBases. |
165 | | bool operator==(const LocalPointerBase<T> &other); |
166 | | bool operator!=(const LocalPointerBase<T> &other); |
167 | | // No ownership sharing: No copy constructor, no assignment operator. |
168 | | LocalPointerBase(const LocalPointerBase<T> &other); |
169 | | void operator=(const LocalPointerBase<T> &other); |
170 | | }; |
171 | | |
172 | | /** |
173 | | * "Smart pointer" class, deletes objects via the standard C++ delete operator. |
174 | | * For most methods see the LocalPointerBase base class. |
175 | | * |
176 | | * Usage example: |
177 | | * \code |
178 | | * LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005)); |
179 | | * int32_t length=s->length(); // 2 |
180 | | * char16_t lead=s->charAt(0); // 0xd900 |
181 | | * if(some condition) { return; } // no need to explicitly delete the pointer |
182 | | * s.adoptInstead(new UnicodeString((char16_t)0xfffc)); |
183 | | * length=s->length(); // 1 |
184 | | * // no need to explicitly delete the pointer |
185 | | * \endcode |
186 | | * |
187 | | * @see LocalPointerBase |
188 | | * @stable ICU 4.4 |
189 | | */ |
190 | | template<typename T> |
191 | | class LocalPointer : public LocalPointerBase<T> { |
192 | | public: |
193 | | using LocalPointerBase<T>::operator*; |
194 | | using LocalPointerBase<T>::operator->; |
195 | | /** |
196 | | * Constructor takes ownership. |
197 | | * @param p simple pointer to an object that is adopted |
198 | | * @stable ICU 4.4 |
199 | | */ |
200 | 0 | explicit LocalPointer(T *p=NULL) : LocalPointerBase<T>(p) {} Unexecuted instantiation: icu_71::LocalPointer<icu_71::CollationTailoring>::LocalPointer(icu_71::CollationTailoring*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UnicodeSet>::LocalPointer(icu_71::UnicodeSet*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::CharString>::LocalPointer(icu_71::CharString*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::StringEnumeration>::LocalPointer(icu_71::StringEnumeration*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UVector>::LocalPointer(icu_71::UVector*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UObject>::LocalPointer(icu_71::UObject*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::ICUServiceFactory>::LocalPointer(icu_71::ICUServiceFactory*) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UnicodeString>::LocalPointer(icu_71::UnicodeString*) |
201 | | /** |
202 | | * Constructor takes ownership and reports an error if NULL. |
203 | | * |
204 | | * This constructor is intended to be used with other-class constructors |
205 | | * that may report a failure UErrorCode, |
206 | | * so that callers need to check only for U_FAILURE(errorCode) |
207 | | * and not also separately for isNull(). |
208 | | * |
209 | | * @param p simple pointer to an object that is adopted |
210 | | * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR |
211 | | * if p==NULL and no other failure code had been set |
212 | | * @stable ICU 55 |
213 | | */ |
214 | 0 | LocalPointer(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p) { |
215 | 0 | if(p==NULL && U_SUCCESS(errorCode)) { |
216 | 0 | errorCode=U_MEMORY_ALLOCATION_ERROR; |
217 | 0 | } |
218 | 0 | } Unexecuted instantiation: icu_71::LocalPointer<icu_71::CharString>::LocalPointer(icu_71::CharString*, UErrorCode&) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UnicodeSet>::LocalPointer(icu_71::UnicodeSet*, UErrorCode&) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UnicodeString>::LocalPointer(icu_71::UnicodeString*, UErrorCode&) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UVector>::LocalPointer(icu_71::UVector*, UErrorCode&) Unexecuted instantiation: umutablecptrie.cpp:icu_71::LocalPointer<icu_71::(anonymous namespace)::MutableCodePointTrie>::LocalPointer(icu_71::(anonymous namespace)::MutableCodePointTrie*, UErrorCode&) |
219 | | /** |
220 | | * Move constructor, leaves src with isNull(). |
221 | | * @param src source smart pointer |
222 | | * @stable ICU 56 |
223 | | */ |
224 | | LocalPointer(LocalPointer<T> &&src) U_NOEXCEPT : LocalPointerBase<T>(src.ptr) { |
225 | | src.ptr=NULL; |
226 | | } |
227 | | |
228 | | /** |
229 | | * Constructs a LocalPointer from a C++11 std::unique_ptr. |
230 | | * The LocalPointer steals the object owned by the std::unique_ptr. |
231 | | * |
232 | | * This constructor works via move semantics. If your std::unique_ptr is |
233 | | * in a local variable, you must use std::move. |
234 | | * |
235 | | * @param p The std::unique_ptr from which the pointer will be stolen. |
236 | | * @stable ICU 64 |
237 | | */ |
238 | | explicit LocalPointer(std::unique_ptr<T> &&p) |
239 | | : LocalPointerBase<T>(p.release()) {} |
240 | | |
241 | | /** |
242 | | * Destructor deletes the object it owns. |
243 | | * @stable ICU 4.4 |
244 | | */ |
245 | 0 | ~LocalPointer() { |
246 | 0 | delete LocalPointerBase<T>::ptr; |
247 | 0 | } Unexecuted instantiation: icu_71::LocalPointer<icu_71::CollationTailoring>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::UnicodeSet>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::CharString>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::StringEnumeration>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::UVector>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::UObject>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::UnicodeString>::~LocalPointer() Unexecuted instantiation: icu_71::LocalPointer<icu_71::ICUServiceFactory>::~LocalPointer() Unexecuted instantiation: umutablecptrie.cpp:icu_71::LocalPointer<icu_71::(anonymous namespace)::MutableCodePointTrie>::~LocalPointer() |
248 | | /** |
249 | | * Move assignment operator, leaves src with isNull(). |
250 | | * The behavior is undefined if *this and src are the same object. |
251 | | * @param src source smart pointer |
252 | | * @return *this |
253 | | * @stable ICU 56 |
254 | | */ |
255 | | LocalPointer<T> &operator=(LocalPointer<T> &&src) U_NOEXCEPT { |
256 | | delete LocalPointerBase<T>::ptr; |
257 | | LocalPointerBase<T>::ptr=src.ptr; |
258 | | src.ptr=NULL; |
259 | | return *this; |
260 | | } |
261 | | |
262 | | /** |
263 | | * Move-assign from an std::unique_ptr to this LocalPointer. |
264 | | * Steals the pointer from the std::unique_ptr. |
265 | | * |
266 | | * @param p The std::unique_ptr from which the pointer will be stolen. |
267 | | * @return *this |
268 | | * @stable ICU 64 |
269 | | */ |
270 | | LocalPointer<T> &operator=(std::unique_ptr<T> &&p) U_NOEXCEPT { |
271 | | adoptInstead(p.release()); |
272 | | return *this; |
273 | | } |
274 | | |
275 | | /** |
276 | | * Swap pointers. |
277 | | * @param other other smart pointer |
278 | | * @stable ICU 56 |
279 | | */ |
280 | | void swap(LocalPointer<T> &other) U_NOEXCEPT { |
281 | | T *temp=LocalPointerBase<T>::ptr; |
282 | | LocalPointerBase<T>::ptr=other.ptr; |
283 | | other.ptr=temp; |
284 | | } |
285 | | /** |
286 | | * Non-member LocalPointer swap function. |
287 | | * @param p1 will get p2's pointer |
288 | | * @param p2 will get p1's pointer |
289 | | * @stable ICU 56 |
290 | | */ |
291 | | friend inline void swap(LocalPointer<T> &p1, LocalPointer<T> &p2) U_NOEXCEPT { |
292 | | p1.swap(p2); |
293 | | } |
294 | | /** |
295 | | * Deletes the object it owns, |
296 | | * and adopts (takes ownership of) the one passed in. |
297 | | * @param p simple pointer to an object that is adopted |
298 | | * @stable ICU 4.4 |
299 | | */ |
300 | 0 | void adoptInstead(T *p) { |
301 | 0 | delete LocalPointerBase<T>::ptr; |
302 | 0 | LocalPointerBase<T>::ptr=p; |
303 | 0 | } |
304 | | /** |
305 | | * Deletes the object it owns, |
306 | | * and adopts (takes ownership of) the one passed in. |
307 | | * |
308 | | * If U_FAILURE(errorCode), then the current object is retained and the new one deleted. |
309 | | * |
310 | | * If U_SUCCESS(errorCode) but the input pointer is NULL, |
311 | | * then U_MEMORY_ALLOCATION_ERROR is set, |
312 | | * the current object is deleted, and NULL is set. |
313 | | * |
314 | | * @param p simple pointer to an object that is adopted |
315 | | * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR |
316 | | * if p==NULL and no other failure code had been set |
317 | | * @stable ICU 55 |
318 | | */ |
319 | 0 | void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode) { |
320 | 0 | if(U_SUCCESS(errorCode)) { |
321 | 0 | delete LocalPointerBase<T>::ptr; |
322 | 0 | LocalPointerBase<T>::ptr=p; |
323 | 0 | if(p==NULL) { |
324 | 0 | errorCode=U_MEMORY_ALLOCATION_ERROR; |
325 | 0 | } |
326 | 0 | } else { |
327 | 0 | delete p; |
328 | 0 | } |
329 | 0 | } Unexecuted instantiation: icu_71::LocalPointer<icu_71::CharString>::adoptInsteadAndCheckErrorCode(icu_71::CharString*, UErrorCode&) Unexecuted instantiation: icu_71::LocalPointer<icu_71::UVector>::adoptInsteadAndCheckErrorCode(icu_71::UVector*, UErrorCode&) |
330 | | |
331 | | /** |
332 | | * Conversion operator to a C++11 std::unique_ptr. |
333 | | * Disowns the object and gives it to the returned std::unique_ptr. |
334 | | * |
335 | | * This operator works via move semantics. If your LocalPointer is |
336 | | * in a local variable, you must use std::move. |
337 | | * |
338 | | * @return An std::unique_ptr owning the pointer previously owned by this |
339 | | * icu::LocalPointer. |
340 | | * @stable ICU 64 |
341 | | */ |
342 | | operator std::unique_ptr<T> () && { |
343 | | return std::unique_ptr<T>(LocalPointerBase<T>::orphan()); |
344 | | } |
345 | | }; |
346 | | |
347 | | /** |
348 | | * "Smart pointer" class, deletes objects via the C++ array delete[] operator. |
349 | | * For most methods see the LocalPointerBase base class. |
350 | | * Adds operator[] for array item access. |
351 | | * |
352 | | * Usage example: |
353 | | * \code |
354 | | * LocalArray<UnicodeString> a(new UnicodeString[2]); |
355 | | * a[0].append((char16_t)0x61); |
356 | | * if(some condition) { return; } // no need to explicitly delete the array |
357 | | * a.adoptInstead(new UnicodeString[4]); |
358 | | * a[3].append((char16_t)0x62).append((char16_t)0x63).reverse(); |
359 | | * // no need to explicitly delete the array |
360 | | * \endcode |
361 | | * |
362 | | * @see LocalPointerBase |
363 | | * @stable ICU 4.4 |
364 | | */ |
365 | | template<typename T> |
366 | | class LocalArray : public LocalPointerBase<T> { |
367 | | public: |
368 | | using LocalPointerBase<T>::operator*; |
369 | | using LocalPointerBase<T>::operator->; |
370 | | /** |
371 | | * Constructor takes ownership. |
372 | | * @param p simple pointer to an array of T objects that is adopted |
373 | | * @stable ICU 4.4 |
374 | | */ |
375 | | explicit LocalArray(T *p=NULL) : LocalPointerBase<T>(p) {} |
376 | | /** |
377 | | * Constructor takes ownership and reports an error if NULL. |
378 | | * |
379 | | * This constructor is intended to be used with other-class constructors |
380 | | * that may report a failure UErrorCode, |
381 | | * so that callers need to check only for U_FAILURE(errorCode) |
382 | | * and not also separately for isNull(). |
383 | | * |
384 | | * @param p simple pointer to an array of T objects that is adopted |
385 | | * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR |
386 | | * if p==NULL and no other failure code had been set |
387 | | * @stable ICU 56 |
388 | | */ |
389 | | LocalArray(T *p, UErrorCode &errorCode) : LocalPointerBase<T>(p) { |
390 | | if(p==NULL && U_SUCCESS(errorCode)) { |
391 | | errorCode=U_MEMORY_ALLOCATION_ERROR; |
392 | | } |
393 | | } |
394 | | /** |
395 | | * Move constructor, leaves src with isNull(). |
396 | | * @param src source smart pointer |
397 | | * @stable ICU 56 |
398 | | */ |
399 | | LocalArray(LocalArray<T> &&src) U_NOEXCEPT : LocalPointerBase<T>(src.ptr) { |
400 | | src.ptr=NULL; |
401 | | } |
402 | | |
403 | | /** |
404 | | * Constructs a LocalArray from a C++11 std::unique_ptr of an array type. |
405 | | * The LocalPointer steals the array owned by the std::unique_ptr. |
406 | | * |
407 | | * This constructor works via move semantics. If your std::unique_ptr is |
408 | | * in a local variable, you must use std::move. |
409 | | * |
410 | | * @param p The std::unique_ptr from which the array will be stolen. |
411 | | * @stable ICU 64 |
412 | | */ |
413 | | explicit LocalArray(std::unique_ptr<T[]> &&p) |
414 | | : LocalPointerBase<T>(p.release()) {} |
415 | | |
416 | | /** |
417 | | * Destructor deletes the array it owns. |
418 | | * @stable ICU 4.4 |
419 | | */ |
420 | | ~LocalArray() { |
421 | | delete[] LocalPointerBase<T>::ptr; |
422 | | } |
423 | | /** |
424 | | * Move assignment operator, leaves src with isNull(). |
425 | | * The behavior is undefined if *this and src are the same object. |
426 | | * @param src source smart pointer |
427 | | * @return *this |
428 | | * @stable ICU 56 |
429 | | */ |
430 | | LocalArray<T> &operator=(LocalArray<T> &&src) U_NOEXCEPT { |
431 | | delete[] LocalPointerBase<T>::ptr; |
432 | | LocalPointerBase<T>::ptr=src.ptr; |
433 | | src.ptr=NULL; |
434 | | return *this; |
435 | | } |
436 | | |
437 | | /** |
438 | | * Move-assign from an std::unique_ptr to this LocalPointer. |
439 | | * Steals the array from the std::unique_ptr. |
440 | | * |
441 | | * @param p The std::unique_ptr from which the array will be stolen. |
442 | | * @return *this |
443 | | * @stable ICU 64 |
444 | | */ |
445 | | LocalArray<T> &operator=(std::unique_ptr<T[]> &&p) U_NOEXCEPT { |
446 | | adoptInstead(p.release()); |
447 | | return *this; |
448 | | } |
449 | | |
450 | | /** |
451 | | * Swap pointers. |
452 | | * @param other other smart pointer |
453 | | * @stable ICU 56 |
454 | | */ |
455 | | void swap(LocalArray<T> &other) U_NOEXCEPT { |
456 | | T *temp=LocalPointerBase<T>::ptr; |
457 | | LocalPointerBase<T>::ptr=other.ptr; |
458 | | other.ptr=temp; |
459 | | } |
460 | | /** |
461 | | * Non-member LocalArray swap function. |
462 | | * @param p1 will get p2's pointer |
463 | | * @param p2 will get p1's pointer |
464 | | * @stable ICU 56 |
465 | | */ |
466 | | friend inline void swap(LocalArray<T> &p1, LocalArray<T> &p2) U_NOEXCEPT { |
467 | | p1.swap(p2); |
468 | | } |
469 | | /** |
470 | | * Deletes the array it owns, |
471 | | * and adopts (takes ownership of) the one passed in. |
472 | | * @param p simple pointer to an array of T objects that is adopted |
473 | | * @stable ICU 4.4 |
474 | | */ |
475 | | void adoptInstead(T *p) { |
476 | | delete[] LocalPointerBase<T>::ptr; |
477 | | LocalPointerBase<T>::ptr=p; |
478 | | } |
479 | | /** |
480 | | * Deletes the array it owns, |
481 | | * and adopts (takes ownership of) the one passed in. |
482 | | * |
483 | | * If U_FAILURE(errorCode), then the current array is retained and the new one deleted. |
484 | | * |
485 | | * If U_SUCCESS(errorCode) but the input pointer is NULL, |
486 | | * then U_MEMORY_ALLOCATION_ERROR is set, |
487 | | * the current array is deleted, and NULL is set. |
488 | | * |
489 | | * @param p simple pointer to an array of T objects that is adopted |
490 | | * @param errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR |
491 | | * if p==NULL and no other failure code had been set |
492 | | * @stable ICU 56 |
493 | | */ |
494 | | void adoptInsteadAndCheckErrorCode(T *p, UErrorCode &errorCode) { |
495 | | if(U_SUCCESS(errorCode)) { |
496 | | delete[] LocalPointerBase<T>::ptr; |
497 | | LocalPointerBase<T>::ptr=p; |
498 | | if(p==NULL) { |
499 | | errorCode=U_MEMORY_ALLOCATION_ERROR; |
500 | | } |
501 | | } else { |
502 | | delete[] p; |
503 | | } |
504 | | } |
505 | | /** |
506 | | * Array item access (writable). |
507 | | * No index bounds check. |
508 | | * @param i array index |
509 | | * @return reference to the array item |
510 | | * @stable ICU 4.4 |
511 | | */ |
512 | | T &operator[](ptrdiff_t i) const { return LocalPointerBase<T>::ptr[i]; } |
513 | | |
514 | | /** |
515 | | * Conversion operator to a C++11 std::unique_ptr. |
516 | | * Disowns the object and gives it to the returned std::unique_ptr. |
517 | | * |
518 | | * This operator works via move semantics. If your LocalPointer is |
519 | | * in a local variable, you must use std::move. |
520 | | * |
521 | | * @return An std::unique_ptr owning the pointer previously owned by this |
522 | | * icu::LocalPointer. |
523 | | * @stable ICU 64 |
524 | | */ |
525 | | operator std::unique_ptr<T[]> () && { |
526 | | return std::unique_ptr<T[]>(LocalPointerBase<T>::orphan()); |
527 | | } |
528 | | }; |
529 | | |
530 | | /** |
531 | | * \def U_DEFINE_LOCAL_OPEN_POINTER |
532 | | * "Smart pointer" definition macro, deletes objects via the closeFunction. |
533 | | * Defines a subclass of LocalPointerBase which works just |
534 | | * like LocalPointer<Type> except that this subclass will use the closeFunction |
535 | | * rather than the C++ delete operator. |
536 | | * |
537 | | * Usage example: |
538 | | * \code |
539 | | * LocalUCaseMapPointer csm(ucasemap_open(localeID, options, &errorCode)); |
540 | | * utf8OutLength=ucasemap_utf8ToLower(csm.getAlias(), |
541 | | * utf8Out, (int32_t)sizeof(utf8Out), |
542 | | * utf8In, utf8InLength, &errorCode); |
543 | | * if(U_FAILURE(errorCode)) { return; } // no need to explicitly delete the UCaseMap |
544 | | * \endcode |
545 | | * |
546 | | * @see LocalPointerBase |
547 | | * @see LocalPointer |
548 | | * @stable ICU 4.4 |
549 | | */ |
550 | | #define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction) \ |
551 | | class LocalPointerClassName : public LocalPointerBase<Type> { \ |
552 | | public: \ |
553 | | using LocalPointerBase<Type>::operator*; \ |
554 | | using LocalPointerBase<Type>::operator->; \ |
555 | 0 | explicit LocalPointerClassName(Type *p=NULL) : LocalPointerBase<Type>(p) {} \ Unexecuted instantiation: icu_71::LocalUSetPointer::LocalUSetPointer(USet*) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::LocalUNormalizer2Pointer(UNormalizer2*) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::LocalUEnumerationPointer(UEnumeration*) Unexecuted instantiation: icu_71::LocalUCollatorPointer::LocalUCollatorPointer(UCollator*) Unexecuted instantiation: icu_71::LocalUCPTriePointer::LocalUCPTriePointer(UCPTrie*) Unexecuted instantiation: icu_71::LocalUHashtablePointer::LocalUHashtablePointer(UHashtable*) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::LocalUResourceBundlePointer(UResourceBundle*) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::LocalUDataMemoryPointer(UDataMemory*) Unexecuted instantiation: icu_71::LocalUTextPointer::LocalUTextPointer(UText*) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::LocalUBreakIteratorPointer(UBreakIterator*) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::LocalUMutableCPTriePointer(UMutableCPTrie*) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::LocalUCaseMapPointer(UCaseMap*) Unexecuted instantiation: icu_71::LocalUConverterPointer::LocalUConverterPointer(UConverter*) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::LocalULanguageTagPointer(ULanguageTag*) |
556 | | LocalPointerClassName(LocalPointerClassName &&src) U_NOEXCEPT \ |
557 | 0 | : LocalPointerBase<Type>(src.ptr) { \ |
558 | 0 | src.ptr=NULL; \ |
559 | 0 | } \ Unexecuted instantiation: icu_71::LocalUSetPointer::LocalUSetPointer(icu_71::LocalUSetPointer&&) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::LocalUNormalizer2Pointer(icu_71::LocalUNormalizer2Pointer&&) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::LocalUEnumerationPointer(icu_71::LocalUEnumerationPointer&&) Unexecuted instantiation: icu_71::LocalUCollatorPointer::LocalUCollatorPointer(icu_71::LocalUCollatorPointer&&) Unexecuted instantiation: icu_71::LocalUCPTriePointer::LocalUCPTriePointer(icu_71::LocalUCPTriePointer&&) Unexecuted instantiation: icu_71::LocalUHashtablePointer::LocalUHashtablePointer(icu_71::LocalUHashtablePointer&&) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::LocalUResourceBundlePointer(icu_71::LocalUResourceBundlePointer&&) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::LocalUDataMemoryPointer(icu_71::LocalUDataMemoryPointer&&) Unexecuted instantiation: icu_71::LocalUTextPointer::LocalUTextPointer(icu_71::LocalUTextPointer&&) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::LocalUBreakIteratorPointer(icu_71::LocalUBreakIteratorPointer&&) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::LocalUMutableCPTriePointer(icu_71::LocalUMutableCPTriePointer&&) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::LocalUCaseMapPointer(icu_71::LocalUCaseMapPointer&&) Unexecuted instantiation: icu_71::LocalUConverterPointer::LocalUConverterPointer(icu_71::LocalUConverterPointer&&) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::LocalULanguageTagPointer(icu_71::LocalULanguageTagPointer&&) |
560 | | /* TODO: Be agnostic of the deleter function signature from the user-provided std::unique_ptr? */ \ |
561 | | explicit LocalPointerClassName(std::unique_ptr<Type, decltype(&closeFunction)> &&p) \ |
562 | 0 | : LocalPointerBase<Type>(p.release()) {} \ Unexecuted instantiation: icu_71::LocalUSetPointer::LocalUSetPointer(std::__1::unique_ptr<USet, void (*)(USet*)>&&) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::LocalUNormalizer2Pointer(std::__1::unique_ptr<UNormalizer2, void (*)(UNormalizer2*)>&&) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::LocalUEnumerationPointer(std::__1::unique_ptr<UEnumeration, void (*)(UEnumeration*)>&&) Unexecuted instantiation: icu_71::LocalUCollatorPointer::LocalUCollatorPointer(std::__1::unique_ptr<UCollator, void (*)(UCollator*)>&&) Unexecuted instantiation: icu_71::LocalUCPTriePointer::LocalUCPTriePointer(std::__1::unique_ptr<UCPTrie, void (*)(UCPTrie*)>&&) Unexecuted instantiation: icu_71::LocalUHashtablePointer::LocalUHashtablePointer(std::__1::unique_ptr<UHashtable, void (*)(UHashtable*)>&&) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::LocalUResourceBundlePointer(std::__1::unique_ptr<UResourceBundle, void (*)(UResourceBundle*)>&&) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::LocalUDataMemoryPointer(std::__1::unique_ptr<UDataMemory, void (*)(UDataMemory*)>&&) Unexecuted instantiation: icu_71::LocalUTextPointer::LocalUTextPointer(std::__1::unique_ptr<UText, UText* (*)(UText*)>&&) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::LocalUBreakIteratorPointer(std::__1::unique_ptr<UBreakIterator, void (*)(UBreakIterator*)>&&) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::LocalUMutableCPTriePointer(std::__1::unique_ptr<UMutableCPTrie, void (*)(UMutableCPTrie*)>&&) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::LocalUCaseMapPointer(std::__1::unique_ptr<UCaseMap, void (*)(UCaseMap*)>&&) Unexecuted instantiation: icu_71::LocalUConverterPointer::LocalUConverterPointer(std::__1::unique_ptr<UConverter, void (*)(UConverter*)>&&) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::LocalULanguageTagPointer(std::__1::unique_ptr<ULanguageTag, void (*)(ULanguageTag*)>&&) |
563 | 0 | ~LocalPointerClassName() { if (ptr != NULL) { closeFunction(ptr); } } \ Unexecuted instantiation: icu_71::LocalUSetPointer::~LocalUSetPointer() Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::~LocalUNormalizer2Pointer() Unexecuted instantiation: icu_71::LocalUEnumerationPointer::~LocalUEnumerationPointer() Unexecuted instantiation: icu_71::LocalUCollatorPointer::~LocalUCollatorPointer() Unexecuted instantiation: icu_71::LocalUCPTriePointer::~LocalUCPTriePointer() Unexecuted instantiation: icu_71::LocalUHashtablePointer::~LocalUHashtablePointer() Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::~LocalUResourceBundlePointer() Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::~LocalUDataMemoryPointer() Unexecuted instantiation: icu_71::LocalUTextPointer::~LocalUTextPointer() Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::~LocalUBreakIteratorPointer() Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::~LocalUMutableCPTriePointer() Unexecuted instantiation: icu_71::LocalUCaseMapPointer::~LocalUCaseMapPointer() Unexecuted instantiation: icu_71::LocalUConverterPointer::~LocalUConverterPointer() Unexecuted instantiation: icu_71::LocalULanguageTagPointer::~LocalULanguageTagPointer() |
564 | 0 | LocalPointerClassName &operator=(LocalPointerClassName &&src) U_NOEXCEPT { \ |
565 | 0 | if (ptr != NULL) { closeFunction(ptr); } \ |
566 | 0 | LocalPointerBase<Type>::ptr=src.ptr; \ |
567 | 0 | src.ptr=NULL; \ |
568 | 0 | return *this; \ |
569 | 0 | } \ Unexecuted instantiation: icu_71::LocalUSetPointer::operator=(icu_71::LocalUSetPointer&&) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::operator=(icu_71::LocalUNormalizer2Pointer&&) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::operator=(icu_71::LocalUEnumerationPointer&&) Unexecuted instantiation: icu_71::LocalUCollatorPointer::operator=(icu_71::LocalUCollatorPointer&&) Unexecuted instantiation: icu_71::LocalUCPTriePointer::operator=(icu_71::LocalUCPTriePointer&&) Unexecuted instantiation: icu_71::LocalUHashtablePointer::operator=(icu_71::LocalUHashtablePointer&&) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::operator=(icu_71::LocalUResourceBundlePointer&&) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::operator=(icu_71::LocalUDataMemoryPointer&&) Unexecuted instantiation: icu_71::LocalUTextPointer::operator=(icu_71::LocalUTextPointer&&) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::operator=(icu_71::LocalUBreakIteratorPointer&&) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::operator=(icu_71::LocalUMutableCPTriePointer&&) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::operator=(icu_71::LocalUCaseMapPointer&&) Unexecuted instantiation: icu_71::LocalUConverterPointer::operator=(icu_71::LocalUConverterPointer&&) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::operator=(icu_71::LocalULanguageTagPointer&&) |
570 | | /* TODO: Be agnostic of the deleter function signature from the user-provided std::unique_ptr? */ \ |
571 | 0 | LocalPointerClassName &operator=(std::unique_ptr<Type, decltype(&closeFunction)> &&p) { \ |
572 | 0 | adoptInstead(p.release()); \ |
573 | 0 | return *this; \ |
574 | 0 | } \ Unexecuted instantiation: icu_71::LocalUSetPointer::operator=(std::__1::unique_ptr<USet, void (*)(USet*)>&&) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::operator=(std::__1::unique_ptr<UNormalizer2, void (*)(UNormalizer2*)>&&) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::operator=(std::__1::unique_ptr<UEnumeration, void (*)(UEnumeration*)>&&) Unexecuted instantiation: icu_71::LocalUCollatorPointer::operator=(std::__1::unique_ptr<UCollator, void (*)(UCollator*)>&&) Unexecuted instantiation: icu_71::LocalUCPTriePointer::operator=(std::__1::unique_ptr<UCPTrie, void (*)(UCPTrie*)>&&) Unexecuted instantiation: icu_71::LocalUHashtablePointer::operator=(std::__1::unique_ptr<UHashtable, void (*)(UHashtable*)>&&) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::operator=(std::__1::unique_ptr<UResourceBundle, void (*)(UResourceBundle*)>&&) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::operator=(std::__1::unique_ptr<UDataMemory, void (*)(UDataMemory*)>&&) Unexecuted instantiation: icu_71::LocalUTextPointer::operator=(std::__1::unique_ptr<UText, UText* (*)(UText*)>&&) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::operator=(std::__1::unique_ptr<UBreakIterator, void (*)(UBreakIterator*)>&&) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::operator=(std::__1::unique_ptr<UMutableCPTrie, void (*)(UMutableCPTrie*)>&&) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::operator=(std::__1::unique_ptr<UCaseMap, void (*)(UCaseMap*)>&&) Unexecuted instantiation: icu_71::LocalUConverterPointer::operator=(std::__1::unique_ptr<UConverter, void (*)(UConverter*)>&&) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::operator=(std::__1::unique_ptr<ULanguageTag, void (*)(ULanguageTag*)>&&) |
575 | 0 | void swap(LocalPointerClassName &other) U_NOEXCEPT { \ |
576 | 0 | Type *temp=LocalPointerBase<Type>::ptr; \ |
577 | 0 | LocalPointerBase<Type>::ptr=other.ptr; \ |
578 | 0 | other.ptr=temp; \ |
579 | 0 | } \ Unexecuted instantiation: icu_71::LocalUSetPointer::swap(icu_71::LocalUSetPointer&) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::swap(icu_71::LocalUNormalizer2Pointer&) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::swap(icu_71::LocalUEnumerationPointer&) Unexecuted instantiation: icu_71::LocalUCollatorPointer::swap(icu_71::LocalUCollatorPointer&) Unexecuted instantiation: icu_71::LocalUCPTriePointer::swap(icu_71::LocalUCPTriePointer&) Unexecuted instantiation: icu_71::LocalUHashtablePointer::swap(icu_71::LocalUHashtablePointer&) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::swap(icu_71::LocalUResourceBundlePointer&) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::swap(icu_71::LocalUDataMemoryPointer&) Unexecuted instantiation: icu_71::LocalUTextPointer::swap(icu_71::LocalUTextPointer&) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::swap(icu_71::LocalUBreakIteratorPointer&) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::swap(icu_71::LocalUMutableCPTriePointer&) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::swap(icu_71::LocalUCaseMapPointer&) Unexecuted instantiation: icu_71::LocalUConverterPointer::swap(icu_71::LocalUConverterPointer&) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::swap(icu_71::LocalULanguageTagPointer&) |
580 | 0 | friend inline void swap(LocalPointerClassName &p1, LocalPointerClassName &p2) U_NOEXCEPT { \ |
581 | 0 | p1.swap(p2); \ |
582 | 0 | } \ Unexecuted instantiation: icu_71::swap(icu_71::LocalUSetPointer&, icu_71::LocalUSetPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUNormalizer2Pointer&, icu_71::LocalUNormalizer2Pointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUEnumerationPointer&, icu_71::LocalUEnumerationPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUCollatorPointer&, icu_71::LocalUCollatorPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUCPTriePointer&, icu_71::LocalUCPTriePointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUHashtablePointer&, icu_71::LocalUHashtablePointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUResourceBundlePointer&, icu_71::LocalUResourceBundlePointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUDataMemoryPointer&, icu_71::LocalUDataMemoryPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUTextPointer&, icu_71::LocalUTextPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUBreakIteratorPointer&, icu_71::LocalUBreakIteratorPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUMutableCPTriePointer&, icu_71::LocalUMutableCPTriePointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUCaseMapPointer&, icu_71::LocalUCaseMapPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalUConverterPointer&, icu_71::LocalUConverterPointer&) Unexecuted instantiation: icu_71::swap(icu_71::LocalULanguageTagPointer&, icu_71::LocalULanguageTagPointer&) |
583 | 0 | void adoptInstead(Type *p) { \ |
584 | 0 | if (ptr != NULL) { closeFunction(ptr); } \ |
585 | 0 | ptr=p; \ |
586 | 0 | } \ Unexecuted instantiation: icu_71::LocalUSetPointer::adoptInstead(USet*) Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::adoptInstead(UNormalizer2*) Unexecuted instantiation: icu_71::LocalUEnumerationPointer::adoptInstead(UEnumeration*) Unexecuted instantiation: icu_71::LocalUCollatorPointer::adoptInstead(UCollator*) Unexecuted instantiation: icu_71::LocalUCPTriePointer::adoptInstead(UCPTrie*) Unexecuted instantiation: icu_71::LocalUHashtablePointer::adoptInstead(UHashtable*) Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::adoptInstead(UResourceBundle*) Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::adoptInstead(UDataMemory*) Unexecuted instantiation: icu_71::LocalUTextPointer::adoptInstead(UText*) Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::adoptInstead(UBreakIterator*) Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::adoptInstead(UMutableCPTrie*) Unexecuted instantiation: icu_71::LocalUCaseMapPointer::adoptInstead(UCaseMap*) Unexecuted instantiation: icu_71::LocalUConverterPointer::adoptInstead(UConverter*) Unexecuted instantiation: icu_71::LocalULanguageTagPointer::adoptInstead(ULanguageTag*) |
587 | 0 | operator std::unique_ptr<Type, decltype(&closeFunction)> () && { \ |
588 | 0 | return std::unique_ptr<Type, decltype(&closeFunction)>(LocalPointerBase<Type>::orphan(), closeFunction); \ |
589 | 0 | } \ Unexecuted instantiation: icu_71::LocalUSetPointer::operator std::__1::unique_ptr<USet, void (*)(USet*)>() && Unexecuted instantiation: icu_71::LocalUNormalizer2Pointer::operator std::__1::unique_ptr<UNormalizer2, void (*)(UNormalizer2*)>() && Unexecuted instantiation: icu_71::LocalUEnumerationPointer::operator std::__1::unique_ptr<UEnumeration, void (*)(UEnumeration*)>() && Unexecuted instantiation: icu_71::LocalUCollatorPointer::operator std::__1::unique_ptr<UCollator, void (*)(UCollator*)>() && Unexecuted instantiation: icu_71::LocalUCPTriePointer::operator std::__1::unique_ptr<UCPTrie, void (*)(UCPTrie*)>() && Unexecuted instantiation: icu_71::LocalUHashtablePointer::operator std::__1::unique_ptr<UHashtable, void (*)(UHashtable*)>() && Unexecuted instantiation: icu_71::LocalUResourceBundlePointer::operator std::__1::unique_ptr<UResourceBundle, void (*)(UResourceBundle*)>() && Unexecuted instantiation: icu_71::LocalUDataMemoryPointer::operator std::__1::unique_ptr<UDataMemory, void (*)(UDataMemory*)>() && Unexecuted instantiation: icu_71::LocalUTextPointer::operator std::__1::unique_ptr<UText, UText* (*)(UText*)>() && Unexecuted instantiation: icu_71::LocalUBreakIteratorPointer::operator std::__1::unique_ptr<UBreakIterator, void (*)(UBreakIterator*)>() && Unexecuted instantiation: icu_71::LocalUMutableCPTriePointer::operator std::__1::unique_ptr<UMutableCPTrie, void (*)(UMutableCPTrie*)>() && Unexecuted instantiation: icu_71::LocalUCaseMapPointer::operator std::__1::unique_ptr<UCaseMap, void (*)(UCaseMap*)>() && Unexecuted instantiation: icu_71::LocalUConverterPointer::operator std::__1::unique_ptr<UConverter, void (*)(UConverter*)>() && Unexecuted instantiation: icu_71::LocalULanguageTagPointer::operator std::__1::unique_ptr<ULanguageTag, void (*)(ULanguageTag*)>() && |
590 | | } |
591 | | |
592 | | U_NAMESPACE_END |
593 | | |
594 | | #endif /* U_SHOW_CPLUSPLUS_API */ |
595 | | #endif /* __LOCALPOINTER_H__ */ |