MapEnsurePtr
MapEnsurePtr
Description
Ensure a key has at least one value and return a pointer to the first value. If the key does not exist, default_value is inserted using r-value semantics.
Parameters
| Name | Direction | Description |
|---|---|---|
m |
in,out | Map. |
key |
in | Key to search or insert. |
default_value |
in | Value to insert if key does not exist. |
Success
Pointer to the first value stored for the key.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Map.Insert.c:84:
bool result;
value_ptr = MapEnsurePtr(&map, 8, 80);
result = value_ptr && (*value_ptr == 80);
result = result && (MapPairCount(&map) == 1);- In
Insert.h:261:
/// Alias for `MapEnsurePtr`.
///
#define MapGetOrInsertPtr(m, lookup_key, default_value) MapEnsurePtr((m), (lookup_key), (default_value))
#endif // MISRA_STD_CONTAINER_MAP_INSERT_H
Last updated on