IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
resizable_operations.hxx
Go to the documentation of this file.
1
3
4#pragma once
6
7namespace ice::string
8{
9
10 using ice::concepts::ResizableStringType;
11
13 {
14 // Capacity and Size Helpers
15
16 template<ResizableStringType Self>
17 inline void shrink(this Self& self) noexcept
18 {
19 self.set_capacity(self.size() + 1);
20 }
21
22 template<ResizableStringType Self>
23 inline void reserve(this Self& self, ice::ncount min_capacity) noexcept
24 {
25 if (min_capacity > self.capacity())
26 {
27 self.set_capacity(min_capacity);
28 }
29 }
30
31 template<ResizableStringType Self>
32 inline void grow(this Self& self, ice::ncount min_capacity = ncount_none) noexcept
33 {
34 ice::ncount const new_capacity = ice::max(self.capacity() * 2 + 8, min_capacity);
35 self.set_capacity(new_capacity);
36 }
37 };
38
39} // namespace ice::string
constexpr auto max(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operations.hxx:49
Definition editable_operations.hxx:9
static constexpr ice::ncount_invalid_t ncount_none
Definition ncount.hxx:60
Definition ncount.hxx:14
Definition editable_operations.hxx:14
Definition resizable_operations.hxx:13
void grow(this Self &self, ice::ncount min_capacity=ncount_none) noexcept
Definition resizable_operations.hxx:32
void shrink(this Self &self) noexcept
Definition resizable_operations.hxx:17
void reserve(this Self &self, ice::ncount min_capacity) noexcept
Definition resizable_operations.hxx:23