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

◆ try_emplace() [4/4]

template<typename Key, typename Value, typename Compare = less<Key>, typename Allocator = allocator_slab<char>>
template<typename... Args>
fl::pair< iterator, bool > fl::MapRedBlackTree< Key, Value, Compare, Allocator >::try_emplace ( Key && key,
Args &&... args )
inline

Definition at line 1266 of file rbtree.h.

1266 {
1267 // Use lower_bound to find position
1268 auto it = mTree.lower_bound(value_type(key, Value()));
1269
1270 // Check if key already exists
1271 if (it != mTree.end() && it->first == key) {
1272 // Key exists, do NOT construct value from args
1273 return fl::pair<iterator, bool>(it, false);
1274 }
1275
1276 // Key doesn't exist, construct value from args and insert with moved key
1277 return mTree.emplace(fl::move(key), fl::forward<Args>(args)...);
1278 }
fl::pair< Key, Value > value_type
Definition rbtree.h:1002