23 static constexpr int capacity = N;
27 typename array_type::iterator _end;
35 small_map(small_map
const &other) {
36 tt_assume(
this != &other);
38 for (ttlet &other_item: other) {
39 auto &this_item = *(_end++);
40 this_item = other_item;
44 small_map(small_map &&other) {
45 tt_assume(
this != &other);
49 for (
auto &other_item: other) {
50 auto &this_item = *(_end++);
51 swap(this_item, other_item);
56 small_map &operator=(small_map
const &other) {
59 for (ttlet &other_item: other) {
60 auto &this_item = *(_end++);
61 this_item = other_item;
67 small_map &operator=(small_map &&other) {
70 for (ttlet &other_item: other) {
71 auto &this_item = *(_end++);
74 other._end = other.begin();
80 return _end - items.
begin();
83 decltype(
auto) begin()
const {
return items.
begin(); }
84 decltype(
auto) begin() {
return items.
begin(); }
85 decltype(
auto) end()
const {
return _end; }
86 decltype(
auto) end() {
return _end; }
90 std::optional<V> get(K
const &key)
const noexcept {
91 for (
auto i = begin(); i != end(); ++i) {
99 V get(K
const &key, V
const &default_value)
const noexcept {
100 if (ttlet &value = get(key)) {
103 return default_value;
107 template<
typename KK,
typename VV>
108 bool set(KK &&key, VV &&value)
noexcept {
110 for (; i != end(); ++i) {
112 i->value = std::forward<VV>(value);
116 if (i != items.
end()) {
118 i->key = std::forward<KK>(key);
119 i->value = std::forward<VV>(value);
126 V increment(K
const &key)
noexcept {
127 static_assert(std::is_arithmetic_v<V>,
"Only increment on a artihmatic value");
129 for (; i != end(); ++i) {
134 if (i != items.
end()) {
137 return i->value = V{1};