65 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___UTILITY_IN_PLACE_H10#define _LIBCPP___UTILITY_IN_PLACE_H11 12#include <__config>13#include <__cstddef/size_t.h>14#include <__type_traits/integral_constant.h>15#include <__type_traits/remove_cvref.h>16 17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18# pragma GCC system_header19#endif20 21_LIBCPP_BEGIN_NAMESPACE_STD22 23#if _LIBCPP_STD_VER >= 1724 25struct in_place_t {26 explicit in_place_t() = default;27};28inline constexpr in_place_t in_place{};29 30template <class _Tp>31struct in_place_type_t {32 _LIBCPP_HIDE_FROM_ABI explicit in_place_type_t() = default;33};34template <class _Tp>35inline constexpr in_place_type_t<_Tp> in_place_type{};36 37template <size_t _Idx>38struct in_place_index_t {39 _LIBCPP_HIDE_FROM_ABI explicit in_place_index_t() = default;40};41template <size_t _Idx>42inline constexpr in_place_index_t<_Idx> in_place_index{};43 44template <class _Tp>45struct __is_inplace_type_imp : false_type {};46template <class _Tp>47struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};48 49template <class _Tp>50using __is_inplace_type _LIBCPP_NODEBUG = __is_inplace_type_imp<__remove_cvref_t<_Tp>>;51 52template <class _Tp>53struct __is_inplace_index_imp : false_type {};54template <size_t _Idx>55struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};56 57template <class _Tp>58using __is_inplace_index _LIBCPP_NODEBUG = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;59 60#endif // _LIBCPP_STD_VER >= 1761 62_LIBCPP_END_NAMESPACE_STD63 64#endif // _LIBCPP___UTILITY_IN_PLACE_H65