[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __memory / auto_ptr.h
blob752143616bb20b8008b53500ff288b11c8734268
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___MEMORY_AUTO_PTR_H
11 #define _LIBCPP___MEMORY_AUTO_PTR_H
13 #include <__config>
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 # pragma GCC system_header
17 #endif
19 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
21 _LIBCPP_BEGIN_NAMESPACE_STD
23 template <class _Tp>
24 struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref {
25 _Tp* __ptr_;
28 template <class _Tp>
29 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr {
30 private:
31 _Tp* __ptr_;
33 public:
34 typedef _Tp element_type;
36 _LIBCPP_HIDE_FROM_ABI explicit auto_ptr(_Tp* __p = 0) _NOEXCEPT : __ptr_(__p) {}
37 _LIBCPP_HIDE_FROM_ABI auto_ptr(auto_ptr& __p) _NOEXCEPT : __ptr_(__p.release()) {}
38 template <class _Up>
39 _LIBCPP_HIDE_FROM_ABI auto_ptr(auto_ptr<_Up>& __p) _NOEXCEPT : __ptr_(__p.release()) {}
40 _LIBCPP_HIDE_FROM_ABI auto_ptr& operator=(auto_ptr& __p) _NOEXCEPT {
41 reset(__p.release());
42 return *this;
44 template <class _Up>
45 _LIBCPP_HIDE_FROM_ABI auto_ptr& operator=(auto_ptr<_Up>& __p) _NOEXCEPT {
46 reset(__p.release());
47 return *this;
49 _LIBCPP_HIDE_FROM_ABI auto_ptr& operator=(auto_ptr_ref<_Tp> __p) _NOEXCEPT {
50 reset(__p.__ptr_);
51 return *this;
53 _LIBCPP_HIDE_FROM_ABI ~auto_ptr() _NOEXCEPT { delete __ptr_; }
55 _LIBCPP_HIDE_FROM_ABI _Tp& operator*() const _NOEXCEPT { return *__ptr_; }
56 _LIBCPP_HIDE_FROM_ABI _Tp* operator->() const _NOEXCEPT { return __ptr_; }
57 _LIBCPP_HIDE_FROM_ABI _Tp* get() const _NOEXCEPT { return __ptr_; }
58 _LIBCPP_HIDE_FROM_ABI _Tp* release() _NOEXCEPT {
59 _Tp* __t = __ptr_;
60 __ptr_ = nullptr;
61 return __t;
63 _LIBCPP_HIDE_FROM_ABI void reset(_Tp* __p = 0) _NOEXCEPT {
64 if (__ptr_ != __p)
65 delete __ptr_;
66 __ptr_ = __p;
69 _LIBCPP_HIDE_FROM_ABI auto_ptr(auto_ptr_ref<_Tp> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
70 template <class _Up>
71 _LIBCPP_HIDE_FROM_ABI operator auto_ptr_ref<_Up>() _NOEXCEPT {
72 auto_ptr_ref<_Up> __t;
73 __t.__ptr_ = release();
74 return __t;
76 template <class _Up>
77 _LIBCPP_HIDE_FROM_ABI operator auto_ptr<_Up>() _NOEXCEPT {
78 return auto_ptr<_Up>(release());
82 template <>
83 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void> {
84 public:
85 typedef void element_type;
88 _LIBCPP_END_NAMESPACE_STD
90 #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
92 #endif // _LIBCPP___MEMORY_AUTO_PTR_H