HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
TTauri
Foundation
small_vector.hpp
1
// Copyright 2019 Pokitec
2
// All rights reserved.
3
4
#pragma once
5
6
#include "TTauri/Foundation/required.hpp"
7
#include <array>
8
9
namespace
tt {
10
11
template
<
typename
T,
size_t
N>
12
class
small_vector
{
13
using
value_type = T;
14
using
array_type
=
std::array<T,N>
;
15
using
iterator =
typename
array_type::iterator;
16
using
const_iterator =
typename
array_type::iterator;
17
18
array_type
items;
19
iterator _end;
20
21
public
:
22
constexpr
small_vector
()
noexcept
{
23
_end = items.
begin
();
24
}
25
26
constexpr
auto
begin()
noexcept
{
27
return
items.
begin
();
28
}
29
30
constexpr
auto
end()
noexcept
{
31
return
_end;
32
}
33
34
constexpr
size_t
size()
const
noexcept
{
35
return
static_cast<
size_t
>
(_end - items.
begin
());
36
}
37
38
constexpr
void
clear()
noexcept
{
39
_end = items.
begin
();
40
}
41
42
constexpr
bool
push_back(value_type &&value)
noexcept
{
43
if
(_end == items.
end
()) {
44
return
false
;
45
}
46
*(_end++) =
std::move
(value);
47
return
true
;
48
}
49
50
constexpr
bool
push_back(value_type
const
&value)
noexcept
{
51
if
(_end == items.
end
()) {
52
return
false
;
53
}
54
*(_end++) = value;
55
return
true
;
56
}
57
58
};
59
60
}
tt::small_vector
Definition
small_vector.hpp:12
std::array< T, N >
std::vector::begin
T begin(T... args)
std::vector::end
T end(T... args)
std::move
T move(T... args)
Generated on Mon Apr 22 2024 12:53:56 for HikoGUI by
1.10.0