From 87c6b54923fb5bc8105d5adecf33b5f7fa926d65 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 17 Aug 2023 12:35:34 +0100 Subject: [PATCH] [Minor] Fix some docs --- src/libutil/cxx/util.hxx | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/libutil/cxx/util.hxx b/src/libutil/cxx/util.hxx index 4ec1d568c..32ec0b55c 100644 --- a/src/libutil/cxx/util.hxx +++ b/src/libutil/cxx/util.hxx @@ -40,6 +40,15 @@ constexpr auto array_of(Ts &&...t) -> std::array(t)...}}; } +/** + * Find a value in a map + * @tparam C Map type + * @tparam K Key type + * @tparam V Value type + * @param c Map to search + * @param k Key to search + * @return Value if found or std::nullopt otherwise + */ template && std::is_constructible_v, bool> = false> constexpr auto find_map(const C &c, const K &k) -> std::optional> { @@ -93,17 +102,18 @@ inline auto string_foreach_line(const S &input, const F &functor) /** * Iterate over elements in a string - * @tparam S - * @tparam F - * @param input - * @param delim - * @param functor - * @param ignore_empty - * @return + * @tparam S string type + * @tparam D delimiter type + * @tparam F functor type + * @param input string to iterate + * @param delim delimiter to use + * @param functor functor to call + * @param ignore_empty ignore empty elements + * @return nothing */ template && std::is_constructible_v && std::is_constructible_v, bool> = true> -inline auto string_foreach_delim(const S &input, const D &delim, const F &functor, const bool ignore_empty = true) +inline auto string_foreach_delim(const S &input, const D &delim, const F &functor, const bool ignore_empty = true) -> void { size_t first = 0; auto sv_input = std::string_view{input}; @@ -124,6 +134,13 @@ inline auto string_foreach_delim(const S &input, const D &delim, const F &functo } } +/** + * Split string on a character + * @tparam S string type + * @param input string to split + * @param chr character to split on + * @return pair of strings + */ template, bool> = true> inline auto string_split_on(const S &input, std::string_view::value_type chr) -> std::pair { @@ -144,6 +161,10 @@ inline auto string_split_on(const S &input, std::string_view::value_type chr) -> /** * Enumerate for range loop + * @tparam T iterable type + * @tparam TIter iterator type + * @param iterable iterable object + * @return iterator object */ template())), -- 2.39.5