Small useful algorithms.
Definition in file algo.hpp.
Go to the source code of this file.
#include <algorithm>
#include <cstddef>
#include <iterator>
#include <optional>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <userver/utils/checked_pointer.hpp>
Namespaces | |
namespace | utils |
Utilities. | |
Functions | |
template<typename ResultString = std::string, typename... Strings> | |
ResultString | utils::StrCat (const Strings &... strings) |
Concatenates multiple std::string_view -convertible items. | |
template<typename Container , typename Key > | |
auto * | utils::FindOrNullptr (Container &container, const Key &key) |
Returns nullptr if no key in associative container, otherwise returns pointer to value. | |
template<typename Container , typename Key , typename Default > | |
auto | utils::FindOrDefault (Container &container, const Key &key, Default &&def) |
Returns default value if no key in associative container, otherwise returns a copy of the stored value. | |
template<typename Container , typename Key > | |
auto | utils::FindOrDefault (Container &container, const Key &key) |
Returns default value if no key in associative container, otherwise returns a copy of the stored value. | |
template<typename Container , typename Key > | |
auto | utils::FindOptional (Container &container, const Key &key) |
Returns std::nullopt if no key in associative container, otherwise returns std::optional with a copy of value. | |
template<typename Container , typename Key > | |
auto | utils::CheckedFind (Container &container, const Key &key) |
Searches a map for an element and return a checked pointer to the found element. | |
template<typename ToContainer , typename FromContainer > | |
ToContainer | utils::AsContainer (FromContainer &&container) |
Converts one container type to another. | |
template<typename Container , typename Pred > | |
auto | utils::EraseIf (Container &container, Pred pred) |
Erased elements and returns number of deleted elements. | |
template<typename Container , typename T > | |
size_t | utils::Erase (Container &container, const T &elem) |
Erased elements and returns number of deleted elements. | |
template<typename Container , typename Pred > | |
bool | utils::ContainsIf (const Container &container, Pred pred) |
returns true if there is an element in container which satisfies the predicate | |