userver: userver/utils/projected_set.hpp File Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
projected_set.hpp File Reference

Detailed Description

A std::unordered_set that compares its elements (of type Value) based on their Projection. It allows to create, essentially, an equivalent of std::unordered_map where keys are stored inside values.

Definition in file projected_set.hpp.

Go to the source code of this file.

#include <functional>
#include <set>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <userver/utils/impl/projecting_view.hpp>
#include <userver/utils/impl/transparent_hash.hpp>
#include <userver/utils/meta_light.hpp>

Namespaces

namespace  utils
 Utilities.
 

Typedefs

template<typename Value, auto Projection, typename Hash = void, typename Equal = std::equal_to<>, typename Allocator = std::allocator<Value>>
using utils::ProjectedUnorderedSet
 A std::unordered_set that compares its elements (of type Value) based on their Projection. It allows to create, essentially, an equivalent of std::unordered_map where keys are stored inside values.
 
template<typename Value, auto Projection, typename Compare = std::less<>, typename Allocator = std::allocator<Value>>
using utils::ProjectedSet = std::set<Value, impl::projected_set::Compare<Value, Projection, Compare>, Allocator>
 Same as utils::ProjectedUnorderedSet, but for std::set.
 

Functions

template<typename Container, typename Value>
void utils::ProjectedInsertOrAssign (Container &set, Value &&value)
 An equivalent of std::unordered_map::insert_or_assign for utils::ProjectedUnorderedSet and utils::ProjectedSet.
 
template<typename Container, typename Key>
auto utils::ProjectedFind (Container &set, const Key &key)
 An equivalent of std::unordered_map::find for utils::ProjectedUnorderedSet and utils::ProjectedSet.