CommonLib
Loading...
Searching...
No Matches
StringTypes.h
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <string>
5#include <tuple>
6#include <type_traits>
7
8namespace hedgedev::csl::ut::expr
9{
10 template <typename T>
12
13 template <typename TChar, typename TTraits>
15
16 template <typename TChar, typename TTraits>
18
19 template <typename T>
20 struct GetCharType<T*> { using Type = std::remove_cv_t<T>; };
21
22 template <typename T, size_t Count>
23 struct GetCharType<T(&)[Count]> { using Type = std::remove_cv_t<T>; };
24
25 template <typename T>
26 struct IsBasicString : std::false_type {};
27
28 template <typename TChar, typename TTraits>
30
31 template <typename T>
32 struct IsBasicStringView : std::false_type {};
33
34 template <typename TChar, typename TTraits>
36
37 ///
38 /// Gets the character type of a string.
39 ///
40 template <typename T>
41 using GetCharType_t = typename GetCharType<std::decay_t<T>>::Type;
42
43 ///
44 /// Checks if the type is an `std::basic_string`.
45 ///
46 template <typename T>
48
49 ///
50 /// Checks if the type is an `std::basic_string_view`.
51 ///
52 template <typename T>
54
55 ///
56 /// A multibyte C string type.
57 ///
58 template <typename T>
60
61 ///
62 /// A wide C string type.
63 ///
64 template <typename T>
66
67 ///
68 /// A multibyte or wide C string type.
69 ///
70 template <typename T>
72
73 ///
74 /// An `std::basic_string` type.
75 ///
76 template <typename T>
78
79 ///
80 /// An `std::basic_string_view` type.
81 ///
82 template <typename T>
84
85 ///
86 /// A multibyte or wide C string type, or an `std::basic_string` or `std::basic_string_view` type.
87 ///
88 template <typename T>
90
91 ///
92 /// Checks if the underlying type of two given string types are the same.
93 ///
94 template <AnyString T1, AnyString T2>
96
97 ///
98 /// An `std::basic_string` inferred from any string type.
99 ///
100 template <AnyString T>
102
103 ///
104 /// An `std::basic_string_view` inferred from any string type.
105 ///
106 template <AnyString T>
108
109 ///
110 /// An `std::basic_string` or `std::basic_string_view` inferred from the string type.
111 ///
112 /// \returns `std::basic_string_view` if the type is a C string. Otherwise, `std::basic_string`.
113 ///
114 template <AnyString T>
116
117 ///
118 /// Creates a string inferred from a string literal at compile time.
119 ///
120 /// \tparam TDst The string type to create.
121 /// \tparam TSrc The string type to convert from.
122 ///
123 /// \param in_rStr The string to create.
124 ///
125 /// \returns The input string in the destination format.
126 ///
127 template <AnyString TDst, AnyString TSrc>
128 inline constexpr TDst CreateInferredString(const TSrc& in_rStr);
129
130 ///
131 /// Determines which string type has the largest character size.
132 ///
133 /// \returns The index of the string type with the largest character size.
134 ///
135 template <AnyString... TArgs>
136 inline constexpr size_t GetStringTypePrecedence();
137
138 ///
139 /// Evaluates the string type with the largest character size.
140 ///
141 template <AnyString... TArgs>
143
144 ///
145 /// An `std::basic_string` inferred from the string type with the largest character size.
146 ///
147 template <AnyString... TArgs>
149
150 ///
151 /// An `std::basic_string_view` inferred from the string type with the largest character size.
152 ///
153 template <AnyString... TArgs>
155
156 ///
157 /// An `std::basic_string` or `std::basic_string_view` inferred from the string type with the largest character size.
158 ///
159 /// \returns `std::basic_string_view` if all types are C strings. Otherwise, `std::basic_string`.
160 ///
161 template <AnyString... TArgs>
165}
166
167#include "StringTypes.inl"
#define ASSERT_RETURN(CONDITION, RETURN_VALUE)
Definition Preprocessor.h:17
Definition StringTypes.h:89
Definition StringTypes.h:83
Definition StringTypes.h:77
Definition StringTypes.h:59
Definition StringTypes.h:65
Definition StringTypes.h:71
bool IsNeighbour(const std::filesystem::path &in_rPath)
Definition ThisProcess.inl:10
std::filesystem::path GetExecutableRoot()
Definition ThisProcess.inl:5
Definition ThisProcess.inl:4
constexpr bool HasFlag(T in_mask, T in_flag)
Definition Expressions.inl:4
constexpr bool IsSameUnderlyingCharType
Definition StringTypes.h:95
std::tuple_element_t< Index, std::tuple< TArgs... > > GetPackType
Definition Expressions.h:9
constexpr bool IsBasicString_v
Definition StringTypes.h:47
constexpr TDst CreateInferredString(const TSrc &in_rStr)
Definition StringTypes.inl:4
constexpr size_t GetStringTypePrecedence()
Definition StringTypes.inl:12
constexpr bool IsBasicStringView_v
Definition StringTypes.h:53
constexpr bool IsAllSame
Definition Expressions.h:15
Definition Expressions.inl:2
Definition StringTypes.h:11
Definition StringTypes.h:26