1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___UTILITY_IN_PLACE_H 10 #define _LIBCPP___UTILITY_IN_PLACE_H 11 12 #include <__config> 13 #include <type_traits> 14 15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 16 #pragma GCC system_header 17 #endif 18 19 _LIBCPP_PUSH_MACROS 20 #include <__undef_macros> 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 #if _LIBCPP_STD_VER > 14 25 26 struct _LIBCPP_TYPE_VIS in_place_t { 27 explicit in_place_t() = default; 28 }; 29 _LIBCPP_INLINE_VAR constexpr in_place_t in_place{}; 30 31 template <class _Tp> 32 struct _LIBCPP_TEMPLATE_VIS in_place_type_t { 33 explicit in_place_type_t() = default; 34 }; 35 template <class _Tp> 36 _LIBCPP_INLINE_VAR constexpr in_place_type_t<_Tp> in_place_type{}; 37 38 template <size_t _Idx> 39 struct _LIBCPP_TEMPLATE_VIS in_place_index_t { 40 explicit in_place_index_t() = default; 41 }; 42 template <size_t _Idx> 43 _LIBCPP_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{}; 44 45 template <class _Tp> struct __is_inplace_type_imp : false_type {}; 46 template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {}; 47 48 template <class _Tp> 49 using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>; 50 51 template <class _Tp> struct __is_inplace_index_imp : false_type {}; 52 template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {}; 53 54 template <class _Tp> 55 using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>; 56 57 #endif // _LIBCPP_STD_VER > 14 58 59 _LIBCPP_END_NAMESPACE_STD 60 61 _LIBCPP_POP_MACROS 62 63 #endif // _LIBCPP___UTILITY_IN_PLACE_H 64