mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Make is_contiguous_back_insert_iterator internal
This commit is contained in:
@ -1216,7 +1216,24 @@ struct wformat_args : basic_format_args<wformat_context> {
|
|||||||
: basic_format_args<wformat_context>(std::forward<Args>(args)...) {}
|
: basic_format_args<wformat_context>(std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Container> struct is_contiguous : std::false_type {};
|
||||||
|
|
||||||
|
template <typename Char>
|
||||||
|
struct is_contiguous<std::basic_string<Char>> : std::true_type {};
|
||||||
|
|
||||||
|
template <typename Char>
|
||||||
|
struct is_contiguous<internal::buffer<Char>> : std::true_type {};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
// Workaround for a SFINAE issue in gcc < 9:
|
||||||
|
// https://stackoverflow.com/q/56436995/471164
|
||||||
|
template <typename OutputIt>
|
||||||
|
struct is_contiguous_back_insert_iterator : std::false_type {};
|
||||||
|
template <typename Container>
|
||||||
|
struct is_contiguous_back_insert_iterator<std::back_insert_iterator<Container>>
|
||||||
|
: is_contiguous<Container> {};
|
||||||
|
|
||||||
template <typename Char> struct named_arg_base {
|
template <typename Char> struct named_arg_base {
|
||||||
basic_string_view<Char> name;
|
basic_string_view<Char> name;
|
||||||
|
|
||||||
@ -1286,26 +1303,12 @@ inline internal::named_arg<T, Char> arg(const S& name, const T& arg) {
|
|||||||
template <typename S, typename T, typename Char>
|
template <typename S, typename T, typename Char>
|
||||||
void arg(S, internal::named_arg<T, Char>) = delete;
|
void arg(S, internal::named_arg<T, Char>) = delete;
|
||||||
|
|
||||||
template <typename Container> struct is_contiguous : std::false_type {};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
struct is_contiguous<std::basic_string<Char>> : std::true_type {};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
struct is_contiguous<internal::buffer<Char>> : std::true_type {};
|
|
||||||
|
|
||||||
template <typename OutputIt>
|
|
||||||
struct is_contiguous_back_insert_iterator : std::false_type {};
|
|
||||||
|
|
||||||
template <typename Container>
|
|
||||||
struct is_contiguous_back_insert_iterator<std::back_insert_iterator<Container>>
|
|
||||||
: is_contiguous<Container> {};
|
|
||||||
|
|
||||||
/** Formats a string and writes the output to ``out``. */
|
/** Formats a string and writes the output to ``out``. */
|
||||||
// GCC 8 and earlier cannot handle std::back_insert_iterator<Container> with
|
// GCC 8 and earlier cannot handle std::back_insert_iterator<Container> with
|
||||||
// vformat_to<ArgFormatter>(...) overload, so SFINAE on iterator type instead.
|
// vformat_to<ArgFormatter>(...) overload, so SFINAE on iterator type instead.
|
||||||
template <typename OutputIt, typename S, typename Char = char_t<S>,
|
template <typename OutputIt, typename S, typename Char = char_t<S>,
|
||||||
FMT_ENABLE_IF(is_contiguous_back_insert_iterator<OutputIt>::value)>
|
FMT_ENABLE_IF(
|
||||||
|
internal::is_contiguous_back_insert_iterator<OutputIt>::value)>
|
||||||
OutputIt vformat_to(OutputIt out, const S& format_str,
|
OutputIt vformat_to(OutputIt out, const S& format_str,
|
||||||
basic_format_args<buffer_context<Char>> args) {
|
basic_format_args<buffer_context<Char>> args) {
|
||||||
using container = typename std::remove_reference<decltype(
|
using container = typename std::remove_reference<decltype(
|
||||||
|
@ -3481,8 +3481,9 @@ struct format_args_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename S, typename OutputIt, typename... Args,
|
template <typename S, typename OutputIt, typename... Args,
|
||||||
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value &&
|
FMT_ENABLE_IF(
|
||||||
!is_contiguous_back_insert_iterator<OutputIt>::value)>
|
internal::is_output_iterator<OutputIt>::value &&
|
||||||
|
!internal::is_contiguous_back_insert_iterator<OutputIt>::value)>
|
||||||
inline OutputIt vformat_to(
|
inline OutputIt vformat_to(
|
||||||
OutputIt out, const S& format_str,
|
OutputIt out, const S& format_str,
|
||||||
typename format_args_t<OutputIt, char_t<S>>::type args) {
|
typename format_args_t<OutputIt, char_t<S>>::type args) {
|
||||||
|
Reference in New Issue
Block a user