in_place.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef _LIBCPP___UTILITY_IN_PLACE_H
  9. #define _LIBCPP___UTILITY_IN_PLACE_H
  10. #include <__config>
  11. #include <type_traits>
  12. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  13. # pragma GCC system_header
  14. #endif
  15. _LIBCPP_BEGIN_NAMESPACE_STD
  16. #if _LIBCPP_STD_VER > 14
  17. struct _LIBCPP_TYPE_VIS in_place_t {
  18. explicit in_place_t() = default;
  19. };
  20. inline constexpr in_place_t in_place{};
  21. template <class _Tp>
  22. struct _LIBCPP_TEMPLATE_VIS in_place_type_t {
  23. explicit in_place_type_t() = default;
  24. };
  25. template <class _Tp>
  26. inline constexpr in_place_type_t<_Tp> in_place_type{};
  27. template <size_t _Idx>
  28. struct _LIBCPP_TEMPLATE_VIS in_place_index_t {
  29. explicit in_place_index_t() = default;
  30. };
  31. template <size_t _Idx>
  32. inline constexpr in_place_index_t<_Idx> in_place_index{};
  33. template <class _Tp> struct __is_inplace_type_imp : false_type {};
  34. template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
  35. template <class _Tp>
  36. using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>;
  37. template <class _Tp> struct __is_inplace_index_imp : false_type {};
  38. template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
  39. template <class _Tp>
  40. using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>;
  41. #endif // _LIBCPP_STD_VER > 14
  42. _LIBCPP_END_NAMESPACE_STD
  43. #endif // _LIBCPP___UTILITY_IN_PLACE_H