HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
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
9namespace tt {
10
11template<typename T,size_t N>
13 using value_type = T;
15 using iterator = typename array_type::iterator;
16 using const_iterator = typename array_type::iterator;
17
18 array_type items;
19 iterator _end;
20
21public:
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}
Definition small_vector.hpp:12
T begin(T... args)
T end(T... args)
T move(T... args)