You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to call fmt::print with a _cf format string results in a compiler warning (or error, when compiling with -pendantic):
#include "fmt/format.h"
#include "fmt/compile.h"
using namespace fmt::literals;
int main() {
fmt::print("{}"_cf, 1);
}
This complains about a ambiguity:
$ g++-11 -std=c++20 tst.cpp -lformat
tst.cpp: In function ‘int main()’:
tst.cpp:7:19: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
7 | fmt::print("{}"_cf, 1);
| ~~~~~~~~~~^~~~~~~~~~~~
In file included from tst.cpp:2:
libs/fmt/include/fmt/compile.h:623:6: note: candidate 1: ‘void fmt::v8::print(const S&, const Args& ...) [with S = fmt::v8::detail::udl_compiled_string<char, 3, fmt::v8::detail_exported::fixed_string<char, 3>{"{}"}>; Args = {int}; typename std::enable_if<fmt::v8::detail::is_compiled_string<S>::value, int>::type <anonymous> = 0]’
623 | void print(const S& format_str, const Args&... args) {
| ^~~~~
In file included from libs/fmt/include/fmt/format.h:48,
from tst.cpp:1:
libs/fmt/include/fmt/core.h:3206:17: note: candidate 2: ‘void fmt::v8::print(fmt::v8::format_string<T ...>, T&& ...) [with T = {int}; fmt::v8::format_string<T ...> = fmt::v8::basic_format_string<char, int>]’
3206 | FMT_INLINE void print(format_string<T...> fmt, T&&... args) {
| ^~~~~
Indeed, commenting out either of the two candidates makes the sample code compile and run successfully. (But that's of course not really a solution, FMT_COMPILE or plain sting literals would no longer work as format strings.)
For fmt::format there is no problem, even thogh it has overloads that look similar.
The text was updated successfully, but these errors were encountered:
Trying to call
fmt::print
with a_cf
format string results in a compiler warning (or error, when compiling with-pendantic
):This complains about a ambiguity:
Indeed, commenting out either of the two candidates makes the sample code compile and run successfully. (But that's of course not really a solution,
FMT_COMPILE
or plain sting literals would no longer work as format strings.)For
fmt::format
there is no problem, even thogh it has overloads that look similar.The text was updated successfully, but these errors were encountered: