File indexing completed on 2026-05-03 08:13:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___FUNCTIONAL_ALLOCATOR_ARG_T_H
0011 #define _LIBCPP___CXX03___FUNCTIONAL_ALLOCATOR_ARG_T_H
0012
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__memory/uses_allocator.h>
0015 #include <__cxx03/__type_traits/integral_constant.h>
0016 #include <__cxx03/__type_traits/is_constructible.h>
0017 #include <__cxx03/__type_traits/remove_cvref.h>
0018 #include <__cxx03/__utility/forward.h>
0019
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 # pragma GCC system_header
0022 #endif
0023
0024 _LIBCPP_BEGIN_NAMESPACE_STD
0025
0026 struct _LIBCPP_TEMPLATE_VIS allocator_arg_t {
0027 explicit allocator_arg_t() = default;
0028 };
0029
0030 #if _LIBCPP_STD_VER >= 17
0031 inline constexpr allocator_arg_t allocator_arg = allocator_arg_t();
0032 #elif !defined(_LIBCPP_CXX03_LANG)
0033 constexpr allocator_arg_t allocator_arg = allocator_arg_t();
0034 #endif
0035
0036 #ifndef _LIBCPP_CXX03_LANG
0037
0038
0039
0040 template <class _Tp, class _Alloc, class... _Args>
0041 struct __uses_alloc_ctor_imp {
0042 typedef _LIBCPP_NODEBUG __remove_cvref_t<_Alloc> _RawAlloc;
0043 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
0044 static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
0045 static const int value = __ua ? 2 - __ic : 0;
0046 };
0047
0048 template <class _Tp, class _Alloc, class... _Args>
0049 struct __uses_alloc_ctor : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> {};
0050
0051 template <class _Tp, class _Allocator, class... _Args>
0052 inline _LIBCPP_HIDE_FROM_ABI void
0053 __user_alloc_construct_impl(integral_constant<int, 0>, _Tp* __storage, const _Allocator&, _Args&&... __args) {
0054 new (__storage) _Tp(std::forward<_Args>(__args)...);
0055 }
0056
0057
0058 template <class _Tp, class _Allocator, class... _Args>
0059 inline _LIBCPP_HIDE_FROM_ABI void
0060 __user_alloc_construct_impl(integral_constant<int, 1>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) {
0061 new (__storage) _Tp(allocator_arg, __a, std::forward<_Args>(__args)...);
0062 }
0063
0064
0065 template <class _Tp, class _Allocator, class... _Args>
0066 inline _LIBCPP_HIDE_FROM_ABI void
0067 __user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) {
0068 new (__storage) _Tp(std::forward<_Args>(__args)..., __a);
0069 }
0070
0071 #endif
0072
0073 _LIBCPP_END_NAMESPACE_STD
0074
0075 #endif