xref: /freebsd/contrib/llvm-project/libcxx/include/__fwd/string.h (revision aa1a8ff2d6dbc51ef058f46f3db5a8bb77967145)
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___FWD_STRING_H
10 #define _LIBCPP___FWD_STRING_H
11 
12 #include <__availability>
13 #include <__config>
14 #include <__fwd/memory_resource.h>
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 template <class _CharT>
23 struct _LIBCPP_TEMPLATE_VIS char_traits;
24 template <>
25 struct char_traits<char>;
26 
27 #ifndef _LIBCPP_HAS_NO_CHAR8_T
28 template <>
29 struct char_traits<char8_t>;
30 #endif
31 
32 template <>
33 struct char_traits<char16_t>;
34 template <>
35 struct char_traits<char32_t>;
36 
37 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
38 template <>
39 struct char_traits<wchar_t>;
40 #endif
41 
42 template <class _Tp>
43 class _LIBCPP_TEMPLATE_VIS allocator;
44 
45 template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
46 class _LIBCPP_TEMPLATE_VIS basic_string;
47 
48 using string = basic_string<char>;
49 
50 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
51 using wstring = basic_string<wchar_t>;
52 #endif
53 
54 #ifndef _LIBCPP_HAS_NO_CHAR8_T
55 using u8string = basic_string<char8_t>;
56 #endif
57 
58 using u16string = basic_string<char16_t>;
59 using u32string = basic_string<char32_t>;
60 
61 #if _LIBCPP_STD_VER >= 17
62 
63 namespace pmr {
64 template <class _CharT, class _Traits = char_traits<_CharT>>
65 using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
66 
67 using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>;
68 
69 #  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
70 using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>;
71 #  endif
72 
73 #  ifndef _LIBCPP_HAS_NO_CHAR8_T
74 using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>;
75 #  endif
76 
77 using u16string _LIBCPP_AVAILABILITY_PMR = basic_string<char16_t>;
78 using u32string _LIBCPP_AVAILABILITY_PMR = basic_string<char32_t>;
79 } // namespace pmr
80 
81 #endif // _LIBCPP_STD_VER >= 17
82 
83 // clang-format off
84 template <class _CharT, class _Traits, class _Allocator>
85 class _LIBCPP_PREFERRED_NAME(string)
86 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
87       _LIBCPP_PREFERRED_NAME(wstring)
88 #endif
89 #ifndef _LIBCPP_HAS_NO_CHAR8_T
90       _LIBCPP_PREFERRED_NAME(u8string)
91 #endif
92       _LIBCPP_PREFERRED_NAME(u16string)
93       _LIBCPP_PREFERRED_NAME(u32string)
94 #if _LIBCPP_STD_VER >= 17
95       _LIBCPP_PREFERRED_NAME(pmr::string)
96 #  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
97       _LIBCPP_PREFERRED_NAME(pmr::wstring)
98 #  endif
99 #  ifndef _LIBCPP_HAS_NO_CHAR8_T
100       _LIBCPP_PREFERRED_NAME(pmr::u8string)
101 #  endif
102       _LIBCPP_PREFERRED_NAME(pmr::u16string)
103       _LIBCPP_PREFERRED_NAME(pmr::u32string)
104 #endif
105       basic_string;
106 // clang-format on
107 
108 _LIBCPP_END_NAMESPACE_STD
109 
110 #endif // _LIBCPP___FWD_STRING_H
111