33#ifndef _RWSTD_RW_UNIQUEPTR_H_INCLUDED
34#define _RWSTD_RW_UNIQUEPTR_H_INCLUDED
36#ifndef _RWSTD_NULLPTR_T
37#define _RWSTD_NULLPTR_T decltype(nullptr)
40#ifndef _RWSTD_RW_DEFS_H_INCLUDED
43#ifndef _RWSTD_RW_FORWARD_INCLUDED
46#ifndef _RWSTD_RW_META_ARR_H_INCLUDED
51 template <
class _TypeT>
52 struct __rw_unique_if;
54 template <
class _TypeT>
55 struct __rw_unique_if<_TypeT[]>;
57 template <
class _TypeT, _RWSTD_SIZE_T _N>
58 struct __rw_unique_if<_TypeT[_N]>;
67template <
class _TypeT>
70 default_delete ()
_THROWS (()) { }
72 template <
class _TypeU>
73 default_delete (
const default_delete<_TypeU>&)
_THROWS (()) { }
75 void operator() (_TypeT* __p)
const _THROWS (()) {
80template <
class _TypeT>
81struct default_delete<_TypeT[]>
83 void operator() (_TypeT* __p)
const _THROWS (()) {
91template <
class _TypeT,
class _Deleter = default_delete<_TypeT> >
95 typedef _TypeT element_type;
96 typedef _Deleter deleter_type;
97 typedef _TypeT* pointer;
102 : _C_ptr (0), _C_del () { }
104#ifndef _RWSTD_NO_NULLPTR
106 : _C_ptr (0), _C_del () { }
109 explicit unique_ptr (pointer __p)
_THROWS (())
110 : _C_ptr (__p), _C_del () { }
112 unique_ptr (pointer __p,
const deleter_type& __d)
_THROWS (())
113 : _C_ptr (__p), _C_del (__d) { }
115#ifndef _RWSTD_NO_RVALUE_REFERENCES
117 unique_ptr (unique_ptr&& __rhs)
_THROWS (())
118 : _C_ptr (__rhs.release ()), _C_del (__rhs._C_del) { }
120 template <
class _TypeU,
class _DeleterU>
121 unique_ptr (unique_ptr<_TypeU, _DeleterU>&& __rhs)
_THROWS (())
122 : _C_ptr (__rhs.release ()), _C_del (__rhs.get_deleter ()) { }
134#ifndef _RWSTD_NO_RVALUE_REFERENCES
136 unique_ptr& operator= (unique_ptr&& __rhs)
_THROWS (()) {
137 reset (__rhs.release ());
142 template <
class _TypeU,
class _DeleterU>
143 unique_ptr& operator= (unique_ptr<_TypeU, _DeleterU>&& __rhs)
_THROWS (()) {
144 reset (__rhs.release ());
158 pointer operator-> ()
const _THROWS (()) {
163 pointer get ()
const _THROWS (()) {
167 deleter_type& get_deleter ()
_THROWS (()) {
171 const deleter_type& get_deleter ()
const _THROWS (()) {
181 pointer release ()
_THROWS (()) {
182 pointer __tmp = _C_ptr;
187 void reset (pointer __p = 0)
_THROWS (()) {
195 void swap (unique_ptr& __other)
_THROWS (()) {
196 pointer __tmp_ptr = _C_ptr;
197 deleter_type __tmp_del = _C_del;
198 _C_ptr = __other._C_ptr;
199 _C_del = __other._C_del;
200 __other._C_ptr = __tmp_ptr;
201 __other._C_del = __tmp_del;
205 unique_ptr (
const unique_ptr&);
206 unique_ptr& operator= (
const unique_ptr&);
215template <
class _TypeT,
class _Deleter>
216class unique_ptr<_TypeT[], _Deleter>
219 typedef _TypeT element_type;
220 typedef _Deleter deleter_type;
221 typedef _TypeT* pointer;
226 : _C_ptr (0), _C_del () { }
228#ifndef _RWSTD_NO_NULLPTR
230 : _C_ptr (0), _C_del () { }
233 explicit unique_ptr (pointer __p)
_THROWS (())
234 : _C_ptr (__p), _C_del () { }
236 unique_ptr (pointer __p,
const deleter_type& __d)
_THROWS (())
237 : _C_ptr (__p), _C_del (__d) { }
239#ifndef _RWSTD_NO_RVALUE_REFERENCES
241 unique_ptr (unique_ptr&& __rhs)
_THROWS (())
242 : _C_ptr (__rhs.release ()), _C_del (__rhs._C_del) { }
254#ifndef _RWSTD_NO_RVALUE_REFERENCES
256 unique_ptr& operator= (unique_ptr&& __rhs)
_THROWS (()) {
257 reset (__rhs.release ());
266 element_type& operator[] (_RWSTD_SIZE_T __i)
const _THROWS (()) {
270 pointer get ()
const _THROWS (()) {
return _C_ptr; }
272 deleter_type& get_deleter ()
_THROWS (()) {
return _C_del; }
274 const deleter_type& get_deleter ()
const _THROWS (()) {
return _C_del; }
276 operator bool ()
const _THROWS (()) {
return 0 != _C_ptr; }
280 pointer release ()
_THROWS (()) {
281 pointer __tmp = _C_ptr;
286 void reset (pointer __p = 0)
_THROWS (()) {
294 void swap (unique_ptr& __other)
_THROWS (()) {
295 pointer __tmp_ptr = _C_ptr;
296 deleter_type __tmp_del = _C_del;
297 _C_ptr = __other._C_ptr;
298 _C_del = __other._C_del;
299 __other._C_ptr = __tmp_ptr;
300 __other._C_del = __tmp_del;
304 unique_ptr (
const unique_ptr&);
305 unique_ptr& operator= (
const unique_ptr&);
314template <
class _TypeT,
class _Deleter>
316swap (unique_ptr<_TypeT, _Deleter>& __lhs,
317 unique_ptr<_TypeT, _Deleter>& __rhs)
_THROWS (())
325template <
class _TypeT,
class _D1,
class _TypeU,
class _D2>
327operator== (
const unique_ptr<_TypeT, _D1>& __lhs,
328 const unique_ptr<_TypeU, _D2>& __rhs)
330 return __lhs.get () == __rhs.get ();
333template <
class _TypeT,
class _D1,
class _TypeU,
class _D2>
335operator!= (
const unique_ptr<_TypeT, _D1>& __lhs,
336 const unique_ptr<_TypeU, _D2>& __rhs)
338 return __lhs.get () != __rhs.get ();
341template <
class _TypeT,
class _D1,
class _TypeU,
class _D2>
343operator< (
const unique_ptr<_TypeT, _D1>& __lhs,
344 const unique_ptr<_TypeU, _D2>& __rhs)
346 return __lhs.get () < __rhs.get ();
349template <
class _TypeT,
class _D1,
class _TypeU,
class _D2>
351operator<= (
const unique_ptr<_TypeT, _D1>& __lhs,
352 const unique_ptr<_TypeU, _D2>& __rhs)
354 return !(__rhs < __lhs);
357template <
class _TypeT,
class _D1,
class _TypeU,
class _D2>
359operator> (
const unique_ptr<_TypeT, _D1>& __lhs,
360 const unique_ptr<_TypeU, _D2>& __rhs)
362 return __rhs < __lhs;
365template <
class _TypeT,
class _D1,
class _TypeU,
class _D2>
367operator>= (
const unique_ptr<_TypeT, _D1>& __lhs,
368 const unique_ptr<_TypeU, _D2>& __rhs)
370 return !(__lhs < __rhs);
373#ifndef _RWSTD_NO_NULLPTR
375template <
class _TypeT,
class _Deleter>
382template <
class _TypeT,
class _Deleter>
389template <
class _TypeT,
class _Deleter>
393 return static_cast<bool> (__p);
396template <
class _TypeT,
class _Deleter>
400 return static_cast<bool> (__p);
403template <
class _TypeT,
class _Deleter>
407 typedef typename unique_ptr<_TypeT, _Deleter>::pointer _Ptr;
408 return __p.get () <
static_cast<_Ptr
> (0);
411template <
class _TypeT,
class _Deleter>
415 typedef typename unique_ptr<_TypeT, _Deleter>::pointer _Ptr;
416 return static_cast<_Ptr
> (0) < __p.get ();
419template <
class _TypeT,
class _Deleter>
423 return !(
nullptr < __p);
426template <
class _TypeT,
class _Deleter>
430 return !(__p <
nullptr);
433template <
class _TypeT,
class _Deleter>
437 return nullptr < __p;
440template <
class _TypeT,
class _Deleter>
444 return __p <
nullptr;
447template <
class _TypeT,
class _Deleter>
451 return !(__p <
nullptr);
454template <
class _TypeT,
class _Deleter>
458 return !(
nullptr < __p);
466#if !defined (_RWSTD_NO_RVALUE_REFERENCES) && \
467 !defined (_RWSTD_NO_VARIADIC_TEMPLATES)
469template <
class _TypeT,
class... _Args>
470inline typename _RW::__rw_unique_if<_TypeT>::__single_object
471make_unique (_Args&&... __args)
473 return unique_ptr<_TypeT>(
new _TypeT (
_RWSTD_FORWARD (_Args, __args)...));
476template <
class _TypeT>
477inline typename _RW::__rw_unique_if<_TypeT>::__unknown_bound
478make_unique (_RWSTD_SIZE_T __n)
480 typedef typename _RW::__rw_remove_extent<_TypeT>::type _TypeU;
481 return unique_ptr<_TypeT>(
new _TypeU[__n]);
491 template <
class _TypeT>
492 struct __rw_unique_if
494 typedef _STD::unique_ptr<_TypeT> __single_object;
497 template <
class _TypeT>
498 struct __rw_unique_if<_TypeT[]>
500 typedef _STD::unique_ptr<_TypeT[]> __unknown_bound;
503 template <
class _TypeT, _RWSTD_SIZE_T _N>
504 struct __rw_unique_if<_TypeT[_N]>
const plus_asgn< T > & operator*(const plus_asgn< T > &lhs, const plus_asgn< T > &rhs)
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_ASSERT(ignore)
#define _RWSTD_FORWARD(_TypeT, __x)
bool operator>(const DistancePair &lhs, const DistancePair &rhs)
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept