Thanks to visit codestin.com
Credit goes to github.com

Skip to content

new compilation error by upgrading from 11.0.1 to 11.1.2 with std::ostreambuf_iterator #4309

@lano1106

Description

@lano1106
In file included from /usr/include/fmt/chrono.h:23,
                 from time_util.cpp:11:
/usr/include/fmt/format.h: In instantiation of ‘constexpr OutputIt fmt::v11::detail::write(OutputIt, T) [with Char = char; OutputIt = std::ostreambuf_iterator<char, std::char_traits<char> >; T = long int; typename std::enable_if<((is_integral<T>::value && (! std::is_same<T, bool>::value)) && (! std::is_same<T, Char>::value)), int>::type <anonymous> = 0]’:
/usr/include/fmt/compile.h:169:25:   required from ‘constexpr OutputIt fmt::v11::detail::field<Char, T, N>::format(OutputIt, const Args& ...) const [with OutputIt = std::ostreambuf_iterator<char, std::char_traits<char> >; Args = {long int, long int}; Char = char; T = long int; int N = 0]’
  169 |       return write<Char>(out, arg);
      |              ~~~~~~~~~~~^~~~~~~~~~
/usr/include/fmt/compile.h:234:21:   required from ‘constexpr OutputIt fmt::v11::detail::concat<L, R>::format(OutputIt, const Args& ...) const [with OutputIt = std::ostreambuf_iterator<char, std::char_traits<char> >; Args = {long int, long int}; L = fmt::v11::detail::field<char, long int, 0>; R = fmt::v11::detail::concat<fmt::v11::detail::code_unit<char>, fmt::v11::detail::spec_field<char, long int, 1> >]’
  234 |     out = lhs.format(out, args...);
      |           ~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/fmt/compile.h:460:19:   required from ‘constexpr OutputIt fmt::v11::format_to(OutputIt, const CompiledFormat&, const Args& ...) [with OutputIt = std::ostreambuf_iterator<char, std::char_traits<char> >; CompiledFormat = detail::concat<detail::field<char, long int, 0>, detail::concat<detail::code_unit<char>, detail::spec_field<char, long int, 1> > >; Args = {long int, long int}; typename std::enable_if<detail::is_compiled_format<CompiledFormat>::value, int>::type <anonymous> = 0]’
  460 |   return cf.format(out, args...);
      |          ~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/fmt/compile.h:500:26:   required from ‘constexpr OutputIt fmt::v11::format_to(OutputIt, const S&, Args&& ...) [with OutputIt = std::ostreambuf_iterator<char, std::char_traits<char> >; S = detail::udl_compiled_string<char, 10, detail::fixed_string<char, 10>{"{}.{:06d}"}>; Args = {const long int&, const long int&}; typename std::enable_if<detail::is_compiled_string<S>::value, int>::type <anonymous> = 0]’
  500 |     return fmt::format_to(out, compiled, std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time_util.cpp:63:19:   required from here
   63 |     fmt::format_to(std::ostreambuf_iterator<char>{o}, "{}.{:06d}"_cf,
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64 |                ts.tv_sec, ts.tv_usec);
      |                ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/format.h:2168:30: error: no matching function for call to ‘format_decimal<char>(std::ostreambuf_iterator<char, std::char_traits<char> >&, long unsigned int&, int&)’
 2168 |   return format_decimal<Char>(out, abs_value, num_digits);
      |          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/format.h:1199:31: note: candidate: ‘template<class Char, class UInt> constexpr Char* fmt::v11::detail::format_decimal(Char*, UInt, int)’
 1199 | FMT_CONSTEXPR FMT_INLINE auto format_decimal(Char* out, UInt value,
      |                               ^~~~~~~~~~~~~~
/usr/include/fmt/format.h:1199:31: note:   template argument deduction/substitution failed:
/usr/include/fmt/format.h:2168:31: note:   cannot convert ‘out’ (type ‘std::ostreambuf_iterator<char, std::char_traits<char> >’) to type ‘char*’
 2168 |   return format_decimal<Char>(out, abs_value, num_digits);
      |                               ^~~
/usr/include/fmt/format.h:1207:20: note: candidate: ‘template<class Char, class UInt, class OutputIt, typename std::enable_if<fmt::v11::detail::is_back_insert_iterator<OutputIt>::value, int>::type <anonymous> > constexpr OutputIt fmt::v11::detail::format_decimal(OutputIt, UInt, int)’
 1207 | FMT_CONSTEXPR auto format_decimal(OutputIt out, UInt value, int num_digits)
      |                    ^~~~~~~~~~~~~~
/usr/include/fmt/format.h:1207:20: note:   template argument deduction/substitution failed:
In file included from /usr/include/fmt/format.h:41:
/usr/include/fmt/format.h:1206:11: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’
 1206 |           FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
      |           ^~~~~~~~~~~~~
make: *** [Makefile:64: time_util.o] Error 1

I have locally fixed the problem by changing the fmt/formt.h template declaration from:

template <typename Char, typename UInt, typename OutputIt,
          FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
FMT_CONSTEXPR auto format_decimal(OutputIt out, UInt value, int num_digits)
    -> OutputIt {

to

template <typename Char, typename UInt, typename OutputIt>
FMT_CONSTEXPR auto format_decimal(OutputIt out, UInt value, int num_digits)
    -> OutputIt {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions