Make ranges only depend on fmt/base.h

This commit is contained in:
Victor Zverovich 2024-01-13 09:44:59 -08:00
parent da0f84c42c
commit d0963d4823
5 changed files with 19 additions and 19 deletions

View File

@ -585,6 +585,17 @@ struct has_to_string_view<
T, void_t<decltype(detail::to_string_view(std::declval<T>()))>>
: std::true_type {};
template <typename CharT, CharT... C> struct string_literal {
static constexpr CharT value[sizeof...(C)] = {C...};
constexpr operator basic_string_view<CharT>() const {
return {value, sizeof...(C)};
}
};
#if FMT_CPLUSPLUS < 201703L
template <typename CharT, CharT... C>
constexpr CharT string_literal<CharT, C...>::value[sizeof...(C)];
#endif
enum class type {
none_type,
// Integer types should go first,

View File

@ -292,18 +292,6 @@ template <typename Char> using std_string_view = std::basic_string_view<Char>;
template <typename T> struct std_string_view {};
#endif
template <typename CharT, CharT... C> struct string_literal {
static constexpr CharT value[sizeof...(C)] = {C...};
constexpr operator basic_string_view<CharT>() const {
return {value, sizeof...(C)};
}
};
#if FMT_CPLUSPLUS < 201703L
template <typename CharT, CharT... C>
constexpr CharT string_literal<CharT, C...>::value[sizeof...(C)];
#endif
// Implementation of std::bit_cast for pre-C++20.
template <typename To, typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {

View File

@ -9,10 +9,11 @@
#define FMT_RANGES_H_
#include <initializer_list>
#include <iterator>
#include <tuple>
#include <type_traits>
#include "format.h"
#include "base.h"
FMT_BEGIN_NAMESPACE
@ -676,12 +677,10 @@ struct formatter<tuple_join_view<Char, T...>, Char> {
typename FormatContext::iterator {
auto out = std::get<sizeof...(T) - N>(formatters_)
.format(std::get<sizeof...(T) - N>(value.tuple), ctx);
if (N > 1) {
out = std::copy(value.sep.begin(), value.sep.end(), out);
ctx.advance_to(out);
return do_format(value, ctx, std::integral_constant<size_t, N - 1>());
}
return out;
if (N <= 1) return out;
out = detail::copy<Char>(value.sep, out);
ctx.advance_to(out);
return do_format(value, ctx, std::integral_constant<size_t, N - 1>());
}
};

View File

@ -7,6 +7,7 @@
#include <vector>
#include "fmt/format.h"
#include "fmt/ranges.h"
#include "gtest/gtest.h"

View File

@ -20,6 +20,7 @@
# include <ranges>
#endif
#include "fmt/format.h"
#include "gtest/gtest.h"
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601