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) {
58 tt_return_on_self_assignment(other);
60 for (ttlet &other_item: other) {
61 auto &this_item = *(_end++);
62 this_item = other_item;
67 small_map &operator=(small_map &&other) {
68 tt_return_on_self_assignment(other);
70 for (ttlet &other_item: other) {
71 auto &this_item = *(_end++);
74 other._end = other.begin();
79 return _end - items.
begin();
82 decltype(
auto) begin()
const {
return items.
begin(); }
83 decltype(
auto) begin() {
return items.
begin(); }
84 decltype(
auto) end()
const {
return _end; }
85 decltype(
auto) end() {
return _end; }
89 std::optional<V> get(K
const &key)
const noexcept {
90 for (
auto i = begin(); i != end(); ++i) {
98 V get(K
const &key, V
const &default_value)
const noexcept {
99 if (ttlet &value = get(key)) {
102 return default_value;
106 template<
typename KK,
typename VV>
107 bool set(KK &&key, VV &&value)
noexcept {
109 for (; i != end(); ++i) {
111 i->value = std::forward<VV>(value);
115 if (i != items.
end()) {
117 i->key = std::forward<KK>(key);
118 i->value = std::forward<VV>(value);
125 V increment(K
const &key)
noexcept {
126 static_assert(std::is_arithmetic_v<V>,
"Only increment on a artihmatic value");
128 for (; i != end(); ++i) {
133 if (i != items.
end()) {
136 return i->value = V{1};