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/remove_cvref.h>
14#include <cstddef>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#if _LIBCPP_STD_VER >= 17
23
24struct _LIBCPP_EXPORTED_FROM_ABI in_place_t {
25 explicit in_place_t() = default;
26};
27inline constexpr in_place_t in_place{};
28
29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS in_place_type_t {
31 _LIBCPP_HIDE_FROM_ABI explicit in_place_type_t() = default;
32};
33template <class _Tp>
34inline constexpr in_place_type_t<_Tp> in_place_type{};
35
36template <size_t _Idx>
37struct _LIBCPP_TEMPLATE_VIS in_place_index_t {
38 _LIBCPP_HIDE_FROM_ABI explicit in_place_index_t() = default;
39};
40template <size_t _Idx>
41inline constexpr in_place_index_t<_Idx> in_place_index{};
42
43template <class _Tp>
44struct __is_inplace_type_imp : false_type {};
45template <class _Tp>
46struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
47
48template <class _Tp>
49using __is_inplace_type = __is_inplace_type_imp<__remove_cvref_t<_Tp>>;
50
51template <class _Tp>
52struct __is_inplace_index_imp : false_type {};
53template <size_t _Idx>
54struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
55
56template <class _Tp>
57using __is_inplace_index = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;
58
59#endif // _LIBCPP_STD_VER >= 17
60
61_LIBCPP_END_NAMESPACE_STD
62
63#endif // _LIBCPP___UTILITY_IN_PLACE_H
64