From 536cabd562831816450ce3f9e57d4da0777ffa9b Mon Sep 17 00:00:00 2001 From: Justin Riddell Date: Fri, 15 Nov 2024 21:01:59 +0000 Subject: [PATCH] Export all range join overloads (#4239) --- include/fmt/ranges.h | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 3bf2224a70fd..118d24fe81a8 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -668,34 +668,6 @@ struct formatter, Char> { } }; -/// Returns a view that formats the iterator range `[begin, end)` with elements -/// separated by `sep`. -template -auto join(It begin, Sentinel end, string_view sep) -> join_view { - return {std::move(begin), end, sep}; -} - -/** - * Returns a view that formats `range` with elements separated by `sep`. - * - * **Example**: - * - * auto v = std::vector{1, 2, 3}; - * fmt::print("{}", fmt::join(v, ", ")); - * // Output: 1, 2, 3 - * - * `fmt::join` applies passed format specifiers to the range elements: - * - * fmt::print("{:02}", fmt::join(v, ", ")); - * // Output: 01, 02, 03 - */ -template ::value)> -auto join(Range&& r, string_view sep) - -> join_view { - return {detail::range_begin(r), detail::range_end(r), sep}; -} - template struct tuple_join_view : detail::view { const Tuple& tuple; basic_string_view sep; @@ -812,6 +784,34 @@ struct formatter< FMT_BEGIN_EXPORT +/// Returns a view that formats the iterator range `[begin, end)` with elements +/// separated by `sep`. +template +auto join(It begin, Sentinel end, string_view sep) -> join_view { + return {std::move(begin), end, sep}; +} + +/** + * Returns a view that formats `range` with elements separated by `sep`. + * + * **Example**: + * + * auto v = std::vector{1, 2, 3}; + * fmt::print("{}", fmt::join(v, ", ")); + * // Output: 1, 2, 3 + * + * `fmt::join` applies passed format specifiers to the range elements: + * + * fmt::print("{:02}", fmt::join(v, ", ")); + * // Output: 01, 02, 03 + */ +template ::value)> +auto join(Range&& r, string_view sep) + -> join_view { + return {detail::range_begin(r), detail::range_end(r), sep}; +} + /** * Returns an object that formats `std::tuple` with elements separated by `sep`. *