mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-08 12:20:06 +00:00
Make ranges only depend on fmt/base.h
This commit is contained in:
parent
da0f84c42c
commit
d0963d4823
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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>());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/ranges.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
# include <ranges>
|
||||
#endif
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601
|
||||
|
Loading…
Reference in New Issue
Block a user