Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___MEMORY_TEMP_VALUE_H
0010 #define _LIBCPP___CXX03___MEMORY_TEMP_VALUE_H
0011 
0012 #include <__cxx03/__config>
0013 #include <__cxx03/__memory/addressof.h>
0014 #include <__cxx03/__memory/allocator_traits.h>
0015 #include <__cxx03/__type_traits/aligned_storage.h>
0016 #include <__cxx03/__utility/forward.h>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 template <class _Tp, class _Alloc>
0025 struct __temp_value {
0026   typedef allocator_traits<_Alloc> _Traits;
0027 
0028 #ifdef _LIBCPP_CXX03_LANG
0029   typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
0030 #else
0031   union {
0032     _Tp __v;
0033   };
0034 #endif
0035   _Alloc& __a;
0036 
0037   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __addr() {
0038 #ifdef _LIBCPP_CXX03_LANG
0039     return reinterpret_cast<_Tp*>(std::addressof(__v));
0040 #else
0041     return std::addressof(__v);
0042 #endif
0043   }
0044 
0045   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& get() { return *__addr(); }
0046 
0047   template <class... _Args>
0048   _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_CONSTEXPR_SINCE_CXX20 __temp_value(_Alloc& __alloc, _Args&&... __args)
0049       : __a(__alloc) {
0050     _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
0051   }
0052 
0053   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__temp_value() { _Traits::destroy(__a, __addr()); }
0054 };
0055 
0056 _LIBCPP_END_NAMESPACE_STD
0057 
0058 #endif // _LIBCPP___CXX03___MEMORY_TEMP_VALUE_H