string.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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___FWD_STRING_H
  9. #define _LIBCPP___FWD_STRING_H
  10. #include <__availability>
  11. #include <__config>
  12. #include <__fwd/memory_resource.h>
  13. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  14. # pragma GCC system_header
  15. #endif
  16. _LIBCPP_BEGIN_NAMESPACE_STD
  17. template <class _CharT>
  18. struct _LIBCPP_TEMPLATE_VIS char_traits;
  19. template <>
  20. struct char_traits<char>;
  21. #ifndef _LIBCPP_HAS_NO_CHAR8_T
  22. template <>
  23. struct char_traits<char8_t>;
  24. #endif
  25. template <>
  26. struct char_traits<char16_t>;
  27. template <>
  28. struct char_traits<char32_t>;
  29. #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  30. template <>
  31. struct char_traits<wchar_t>;
  32. #endif
  33. template <class _Tp>
  34. class _LIBCPP_TEMPLATE_VIS allocator;
  35. template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
  36. class _LIBCPP_TEMPLATE_VIS basic_string;
  37. using string = basic_string<char>;
  38. #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  39. using wstring = basic_string<wchar_t>;
  40. #endif
  41. #ifndef _LIBCPP_HAS_NO_CHAR8_T
  42. using u8string = basic_string<char8_t>;
  43. #endif
  44. using u16string = basic_string<char16_t>;
  45. using u32string = basic_string<char32_t>;
  46. #if _LIBCPP_STD_VER >= 17
  47. namespace pmr {
  48. template <class _CharT, class _Traits = char_traits<_CharT>>
  49. using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
  50. using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>;
  51. # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  52. using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>;
  53. # endif
  54. # ifndef _LIBCPP_HAS_NO_CHAR8_T
  55. using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>;
  56. # endif
  57. using u16string _LIBCPP_AVAILABILITY_PMR = basic_string<char16_t>;
  58. using u32string _LIBCPP_AVAILABILITY_PMR = basic_string<char32_t>;
  59. } // namespace pmr
  60. #endif // _LIBCPP_STD_VER >= 17
  61. // clang-format off
  62. template <class _CharT, class _Traits, class _Allocator>
  63. class _LIBCPP_PREFERRED_NAME(string)
  64. #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  65. _LIBCPP_PREFERRED_NAME(wstring)
  66. #endif
  67. #ifndef _LIBCPP_HAS_NO_CHAR8_T
  68. _LIBCPP_PREFERRED_NAME(u8string)
  69. #endif
  70. _LIBCPP_PREFERRED_NAME(u16string)
  71. _LIBCPP_PREFERRED_NAME(u32string)
  72. #if _LIBCPP_STD_VER >= 17
  73. _LIBCPP_PREFERRED_NAME(pmr::string)
  74. # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
  75. _LIBCPP_PREFERRED_NAME(pmr::wstring)
  76. # endif
  77. # ifndef _LIBCPP_HAS_NO_CHAR8_T
  78. _LIBCPP_PREFERRED_NAME(pmr::u8string)
  79. # endif
  80. _LIBCPP_PREFERRED_NAME(pmr::u16string)
  81. _LIBCPP_PREFERRED_NAME(pmr::u32string)
  82. #endif
  83. basic_string;
  84. // clang-format on
  85. _LIBCPP_END_NAMESPACE_STD
  86. #endif // _LIBCPP___FWD_STRING_H