Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/libutil/include/nix/util/util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ std::pair<std::string_view, std::string_view> getLine(std::string_view s);
/**
* Get a value for the specified key from an associate container.
*/
template<class T>
const typename T::mapped_type * get(const T & map, const typename T::key_type & key)
template<class T, typename K>
const typename T::mapped_type * get(const T & map, K & key)
{
auto i = map.find(key);
if (i == map.end())
return nullptr;
return &i->second;
}

template<class T>
typename T::mapped_type * get(T & map, const typename T::key_type & key)
template<class T, typename K>
typename T::mapped_type * get(T & map, K & key)
{
auto i = map.find(key);
if (i == map.end())
Expand All @@ -221,9 +221,8 @@ typename T::mapped_type * get(T && map, const typename T::key_type & key) = dele
/**
* Get a value for the specified key from an associate container, or a default value if the key isn't present.
*/
template<class T>
const typename T::mapped_type &
getOr(T & map, const typename T::key_type & key, const typename T::mapped_type & defaultValue)
template<class T, typename K>
const typename T::mapped_type & getOr(T & map, K & key, const typename T::mapped_type & defaultValue)
{
auto i = map.find(key);
if (i == map.end())
Expand Down
Loading