Template Function find_opt

Function Documentation

template<typename Map, typename Key>
std::optional<typename Map::mapped_type> find_opt(const Map &m, const Key &k)

Finds a value in a map and returns it as an optional.

Template Parameters:
  • Map – The type of the map.

  • Key – The type of the key.

Returns:

An optional containing the value if the key is found, std::nullopt otherwise.