IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
string_concepts.hxx
Go to the documentation of this file.
1
3
4#pragma once
7
8namespace ice::concepts
9{
10
11 template<typename CharType>
12 concept SupportedCharType = std::is_same_v<CharType, char>
13 //|| std::is_same_v<CharType, char8_t>
14 || std::is_same_v<CharType, wchar_t>;
15
16 template<typename SizeType>
17 concept SupportedSizeType = std::is_same_v<SizeType, ice::ncount>;
18
19 template<typename T>
22 && requires(T const& t)
23 {
24 typename T::StringType;
25 typename T::ValueType;
26 typename T::ConstIterator;
27 typename T::ConstReverseIterator;
28 { t.data() } -> std::convertible_to<typename T::CharType const*>;
29 { t.size() } -> std::convertible_to<typename T::SizeType>;
30 };
31
32 template<typename T>
34 && requires(T& t, typename T::SizeType size_value)
35 {
36 { t.data() } -> std::convertible_to<typename T::CharType*>;
37 { t.capacity() } -> std::convertible_to<typename T::SizeType>;
38 { t.resize(size_value) } -> std::convertible_to<void>;
39 };
40
41 template<typename T>
43 && requires(T& t, typename T::SizeType capacity_value)
44 {
45 { t.set_capacity(capacity_value) } -> std::convertible_to<void>;
46 };
47
48} // namespace ice::concepts
49
50namespace ice::string
51{
52
53 template<ice::concepts::StringType StringT>
54 using ConstCorrectCharType = std::conditional_t<
55 std::is_const_v<typename std::remove_reference_t<StringT>>,
56 typename std::remove_reference_t<StringT>::CharType const,
57 typename std::remove_reference_t<StringT>::CharType
58 >;
59
60 template<ice::concepts::StringType StringT>
62
63 template<ice::concepts::StringType StringT>
64 using String = typename StringT::StringType;
65
66} // namespace ice::string
67
69{
70
71 template<typename CharType>
72 constexpr auto strptr_size(CharType const* str) noexcept -> ice::ncount::base_type
73 {
75 if (str != nullptr)
76 {
77 CharType const* it = str;
78 while (*it != CharType{ 0 })
79 {
80 it += 1;
81 }
82
83 result = static_cast<ice::ncount::base_type>(it - str);
84 }
85 return result;
86 }
87
88} // namespace string::detail
89
90namespace ice
91{
92
94
95} // namespace ice
Definition string_concepts.hxx:33
Definition string_concepts.hxx:42
Definition string_concepts.hxx:20
Definition string_concepts.hxx:12
Definition string_concepts.hxx:17
Definition container_concepts.hxx:12
Definition string_concepts.hxx:69
constexpr auto strptr_size(CharType const *str) noexcept -> ice::ncount::base_type
Definition string_concepts.hxx:72
Definition editable_operations.hxx:9
std::conditional_t< std::is_const_v< typename std::remove_reference_t< StringT > >, typename std::remove_reference_t< StringT >::CharType const, typename std::remove_reference_t< StringT >::CharType > ConstCorrectCharType
Definition string_concepts.hxx:54
typename StringT::StringType String
Definition string_concepts.hxx:64
ConstCorrectCharType< StringT > CharType
Definition string_concepts.hxx:61
SPDX-License-Identifier: MIT.
Definition array.hxx:12
ice::detail::nvalue_base_utype base_type
Definition nvalue.hxx:75