Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:56

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___MEMORY_AUTO_PTR_H
0011 #define _LIBCPP___MEMORY_AUTO_PTR_H
0012 
0013 #include <__config>
0014 
0015 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0016 #  pragma GCC system_header
0017 #endif
0018 
0019 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
0020 
0021 _LIBCPP_BEGIN_NAMESPACE_STD
0022 
0023 template <class _Tp>
0024 struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref {
0025   _Tp* __ptr_;
0026 };
0027 
0028 template <class _Tp>
0029 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr {
0030 private:
0031   _Tp* __ptr_;
0032 
0033 public:
0034   typedef _Tp element_type;
0035 
0036   _LIBCPP_HIDE_FROM_ABI explicit auto_ptr(_Tp* __p = 0) _NOEXCEPT : __ptr_(__p) {}
0037   _LIBCPP_HIDE_FROM_ABI auto_ptr(auto_ptr& __p) _NOEXCEPT : __ptr_(__p.release()) {}
0038   template <class _Up>
0039   _LIBCPP_HIDE_FROM_ABI auto_ptr(auto_ptr<_Up>& __p) _NOEXCEPT : __ptr_(__p.release()) {}
0040   _LIBCPP_HIDE_FROM_ABI auto_ptr& operator=(auto_ptr& __p) _NOEXCEPT {
0041     reset(__p.release());
0042     return *this;
0043   }
0044   template <class _Up>
0045   _LIBCPP_HIDE_FROM_ABI auto_ptr& operator=(auto_ptr<_Up>& __p) _NOEXCEPT {
0046     reset(__p.release());
0047     return *this;
0048   }
0049   _LIBCPP_HIDE_FROM_ABI auto_ptr& operator=(auto_ptr_ref<_Tp> __p) _NOEXCEPT {
0050     reset(__p.__ptr_);
0051     return *this;
0052   }
0053   _LIBCPP_HIDE_FROM_ABI ~auto_ptr() _NOEXCEPT { delete __ptr_; }
0054 
0055   _LIBCPP_HIDE_FROM_ABI _Tp& operator*() const _NOEXCEPT { return *__ptr_; }
0056   _LIBCPP_HIDE_FROM_ABI _Tp* operator->() const _NOEXCEPT { return __ptr_; }
0057   _LIBCPP_HIDE_FROM_ABI _Tp* get() const _NOEXCEPT { return __ptr_; }
0058   _LIBCPP_HIDE_FROM_ABI _Tp* release() _NOEXCEPT {
0059     _Tp* __t = __ptr_;
0060     __ptr_   = nullptr;
0061     return __t;
0062   }
0063   _LIBCPP_HIDE_FROM_ABI void reset(_Tp* __p = 0) _NOEXCEPT {
0064     if (__ptr_ != __p)
0065       delete __ptr_;
0066     __ptr_ = __p;
0067   }
0068 
0069   _LIBCPP_HIDE_FROM_ABI auto_ptr(auto_ptr_ref<_Tp> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
0070   template <class _Up>
0071   _LIBCPP_HIDE_FROM_ABI operator auto_ptr_ref<_Up>() _NOEXCEPT {
0072     auto_ptr_ref<_Up> __t;
0073     __t.__ptr_ = release();
0074     return __t;
0075   }
0076   template <class _Up>
0077   _LIBCPP_HIDE_FROM_ABI operator auto_ptr<_Up>() _NOEXCEPT {
0078     return auto_ptr<_Up>(release());
0079   }
0080 };
0081 
0082 template <>
0083 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void> {
0084 public:
0085   typedef void element_type;
0086 };
0087 
0088 _LIBCPP_END_NAMESPACE_STD
0089 
0090 #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
0091 
0092 #endif // _LIBCPP___MEMORY_AUTO_PTR_H