24 static constexpr int capacity = N;
28 typename array_type::iterator _end;
36 small_map(small_map
const &other) {
37 tt_axiom(
this != &other);
39 for (ttlet &other_item: other) {
40 auto &this_item = *(_end++);
41 this_item = other_item;
45 small_map(small_map &&other) {
46 tt_axiom(
this != &other);
50 for (
auto &other_item: other) {
51 auto &this_item = *(_end++);
52 swap(this_item, other_item);
57 small_map &operator=(small_map
const &other) {
60 for (ttlet &other_item: other) {
61 auto &this_item = *(_end++);
62 this_item = other_item;
68 small_map &operator=(small_map &&other) {
71 for (ttlet &other_item: other) {
72 auto &this_item = *(_end++);
75 other._end = other.begin();
81 return _end - items.
begin();
84 decltype(
auto) begin()
const {
return items.
begin(); }
85 decltype(
auto) begin() {
return items.
begin(); }
86 decltype(
auto) end()
const {
return _end; }
87 decltype(
auto) end() {
return _end; }
91 std::optional<V> get(K
const &key)
const noexcept {
92 for (
auto i = begin(); i != end(); ++i) {
100 V get(K
const &key, V
const &default_value)
const noexcept {
101 if (ttlet &value = get(key)) {
104 return default_value;
108 template<
typename KK,
typename VV>
109 bool set(KK &&key, VV &&value)
noexcept {
111 for (; i != end(); ++i) {
113 i->value = std::forward<VV>(value);
117 if (i != items.
end()) {
119 i->key = std::forward<KK>(key);
120 i->value = std::forward<VV>(value);
127 V increment(K
const &key)
noexcept {
128 static_assert(std::is_arithmetic_v<V>,
"Only increment on a artihmatic value");
130 for (; i != end(); ++i) {
135 if (i != items.
end()) {
138 return i->value = V{1};