IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
collections
public
ice
string
string_concepts.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/types/ncount.hxx
>
6
#include <
ice/types/nindex.hxx
>
7
8
namespace
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>
20
concept
StringType
=
SupportedCharType<typename T::CharType>
21
&&
SupportedSizeType<typename T::SizeType>
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>
33
concept
MutableStringType
=
StringType<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>
42
concept
ResizableStringType
=
MutableStringType<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
50
namespace
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>
61
using
CharType
=
ConstCorrectCharType<StringT>
;
62
63
template
<ice::concepts::StringType StringT>
64
using
String
=
typename
StringT::StringType;
65
66
}
// namespace ice::string
67
68
namespace
ice::string::detail
69
{
70
71
template
<
typename
CharType>
72
constexpr
auto
strptr_size
(
CharType
const
* str)
noexcept
->
ice::ncount::base_type
73
{
74
ice::ncount::base_type
result{};
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
90
namespace
ice
91
{
92
93
using
ice::concepts::StringType
;
94
95
}
// namespace ice
ice::concepts::MutableStringType
Definition
string_concepts.hxx:33
ice::concepts::ResizableStringType
Definition
string_concepts.hxx:42
ice::concepts::StringType
Definition
string_concepts.hxx:20
ice::concepts::SupportedCharType
Definition
string_concepts.hxx:12
ice::concepts::SupportedSizeType
Definition
string_concepts.hxx:17
ice::concepts
Definition
container_concepts.hxx:12
ice::string::detail
Definition
string_concepts.hxx:69
ice::string::detail::strptr_size
constexpr auto strptr_size(CharType const *str) noexcept -> ice::ncount::base_type
Definition
string_concepts.hxx:72
ice::string
Definition
editable_operations.hxx:9
ice::string::ConstCorrectCharType
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
ice::string::String
typename StringT::StringType String
Definition
string_concepts.hxx:64
ice::string::CharType
ConstCorrectCharType< StringT > CharType
Definition
string_concepts.hxx:61
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ncount.hxx
nindex.hxx
ice::ncount::base_type
ice::detail::nvalue_base_utype base_type
Definition
nvalue.hxx:75
Generated by
1.18.0