HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
container
small_vector.hpp
1
// Copyright Take Vos 2019, 2021.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
#pragma once
6
7
#include "../utility/utility.hpp"
8
#include "../macros.hpp"
9
#include <array>
10
11
12
13
namespace
hi::inline
v1
{
14
15
template
<
typename
T, std::
size_t
N>
16
class
small_vector
{
17
using
value_type = T;
18
using
array_type
=
std::array<T, N>
;
19
using
iterator =
typename
array_type::iterator;
20
using
const_iterator =
typename
array_type::iterator;
21
22
array_type
items;
23
iterator _end;
24
25
public
:
26
constexpr
small_vector
()
noexcept
27
{
28
_end = items.
begin
();
29
}
30
31
constexpr
auto
begin()
noexcept
32
{
33
return
items.
begin
();
34
}
35
36
constexpr
auto
end()
noexcept
37
{
38
return
_end;
39
}
40
41
constexpr
std::size_t
size()
const
noexcept
42
{
43
return
static_cast<
std::size_t
>
(_end - items.
begin
());
44
}
45
46
constexpr
void
clear()
noexcept
47
{
48
_end = items.
begin
();
49
}
50
51
constexpr
bool
push_back(value_type &&value)
noexcept
52
{
53
if
(_end == items.
end
()) {
54
return
false
;
55
}
56
*(_end++) =
std::move
(value);
57
return
true
;
58
}
59
60
constexpr
bool
push_back(value_type
const
&value)
noexcept
61
{
62
if
(_end == items.
end
()) {
63
return
false
;
64
}
65
*(_end++) = value;
66
return
true
;
67
}
68
};
69
70
}
// namespace hi::inline v1
v1
DOXYGEN BUG.
Definition
algorithm.hpp:16
hi::v1::narrow_cast
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition
cast.hpp:377
v1::small_vector
Definition
small_vector.hpp:16
std::array< T, N >
std::array::begin
T begin(T... args)
std::array::end
T end(T... args)
std::move
T move(T... args)
std::size_t
Generated on Mon Apr 22 2024 12:53:15 for HikoGUI by
1.10.0