FastLED 3.9.15
Loading...
Searching...
No Matches

◆ operator[]()

template<typename Key, typename Value, typename Less = fl::less<Key>>
Value & fl::flat_map< Key, Value, Less >::operator[] ( const Key & key)
inline

Definition at line 103 of file flat_map.h.

103 {
104 auto it = lower_bound(key);
105 if (it != end() && !mLess(key, it->first) && !mLess(it->first, key)) {
106 return it->second;
107 }
108 // Key not found, insert it with default value
109 bool success = mData.insert(it, value_type(key, Value()));
110 FASTLED_ASSERT(success, "Insert failed in flat_map::operator[]");
111 // Find the newly inserted element
112 it = find(key);
113 return it->second;
114 }
fl::pair< Key, Value > value_type
Definition flat_map.h:35
iterator lower_bound(const Key &key) FL_NOEXCEPT
Definition flat_map.h:166
iterator end() FL_NOEXCEPT
Definition flat_map.h:84
iterator find(const Key &key) FL_NOEXCEPT
Definition flat_map.h:136
vector_type mData
Definition flat_map.h:51