HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
ttauri
small_vector.hpp
1
// Copyright Take Vos 2019.
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 "required.hpp"
8
#include <array>
9
10
namespace
tt {
11
12
template
<
typename
T,
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
_end = items.
begin
();
25
}
26
27
constexpr
auto
begin()
noexcept
{
28
return
items.
begin
();
29
}
30
31
constexpr
auto
end()
noexcept
{
32
return
_end;
33
}
34
35
constexpr
size_t
size()
const
noexcept
{
36
return
static_cast<
size_t
>
(_end - items.
begin
());
37
}
38
39
constexpr
void
clear()
noexcept
{
40
_end = items.
begin
();
41
}
42
43
constexpr
bool
push_back(value_type &&value)
noexcept
{
44
if
(_end == items.
end
()) {
45
return
false
;
46
}
47
*(_end++) =
std::move
(value);
48
return
true
;
49
}
50
51
constexpr
bool
push_back(value_type
const
&value)
noexcept
{
52
if
(_end == items.
end
()) {
53
return
false
;
54
}
55
*(_end++) = value;
56
return
true
;
57
}
58
59
};
60
61
}
tt::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)
Generated on Mon Apr 22 2024 12:53:45 for HikoGUI by
1.10.0