HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
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.hpp
"
8
#include <array>
9
10
namespace
hi::inline
v1
{
11
12
template
<
typename
T, std::
size_t
N>
13
class
small_vector
{
14
using
value_type = T;
15
using
array_type
=
std::array<T, N>
;
16
using
iterator =
typename
array_type::iterator;
17
using
const_iterator =
typename
array_type::iterator;
18
19
array_type
items;
20
iterator _end;
21
22
public
:
23
constexpr
small_vector
()
noexcept
24
{
25
_end = items.
begin
();
26
}
27
28
constexpr
auto
begin()
noexcept
29
{
30
return
items.
begin
();
31
}
32
33
constexpr
auto
end()
noexcept
34
{
35
return
_end;
36
}
37
38
constexpr
std::size_t
size()
const
noexcept
39
{
40
return
static_cast<
std::size_t
>
(_end - items.
begin
());
41
}
42
43
constexpr
void
clear()
noexcept
44
{
45
_end = items.
begin
();
46
}
47
48
constexpr
bool
push_back(value_type &&value)
noexcept
49
{
50
if
(_end == items.
end
()) {
51
return
false
;
52
}
53
*(_end++) =
std::move
(value);
54
return
true
;
55
}
56
57
constexpr
bool
push_back(value_type
const
&value)
noexcept
58
{
59
if
(_end == items.
end
()) {
60
return
false
;
61
}
62
*(_end++) = value;
63
return
true
;
64
}
65
};
66
67
}
// namespace hi::inline v1
utility.hpp
Utilities used by the HikoGUI library itself.
v1
DOXYGEN BUG.
Definition
algorithm.hpp:15
v1::small_vector
Definition
small_vector.hpp:13
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:52:09 for HikoGUI by
1.10.0