CommonLib
Loading...
Searching...
No Matches
string_expr.inl
Go to the documentation of this file.
1#include <tuple>
2
3namespace hedgedev::csl::ut::expr
4{
5 template <any_string T_result, any_string T_str>
6 inline constexpr T_result create_inferred_string(const T_str& in_str)
7 {
8 T_result result{};
9
10 const auto str_sv = inferred_string_view_t<T_str>(in_str);
11
12 result.reserve(str_sv.size() * sizeof(get_char_type_t<T_result>));
13
14 std::transform(str_sv.begin(), str_sv.end(), std::back_inserter(result), [](get_char_type_t<T_str> in_char)
15 {
16 return static_cast<get_char_type_t<T_result>>(in_char);
17 });
18
19 return result;
20 }
21
22 template <any_string... T_args>
24 {
25 std::tuple<size_t, size_t> result{ 0, 0 };
26 size_t i{};
27
28 (
29 [&]
30 {
31 size_t size = sizeof(get_char_type_t<T_args>);
32
33 if (std::get<1>(result) < size)
34 result = { i, size };
35
36 i++;
37 }
38
39 (), ...
40 );
41
42 return std::get<0>(result);
43 }
44}
constexpr size_t get_string_type_precedence()
Definition string_expr.inl:23
constexpr T_result create_inferred_string(const T_str &in_str)
Definition string_expr.inl:6
Definition expr.h:7