mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-25 11:40:06 +00:00
Fix ADL issues
This commit is contained in:
parent
61b4c923d7
commit
63271a51c4
@ -2816,7 +2816,7 @@ template <typename OutputIt, typename... T,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
|
||||
inline auto format_to(OutputIt out, format_string<T...> fmt, T&&... args)
|
||||
-> OutputIt {
|
||||
return vformat_to(out, fmt, make_format_args(args...));
|
||||
return vformat_to(out, fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt> struct format_to_n_result {
|
||||
@ -2848,14 +2848,14 @@ template <typename OutputIt, typename... T,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>
|
||||
inline auto format_to_n(OutputIt out, size_t n, format_string<T...> fmt,
|
||||
const T&... args) -> format_to_n_result<OutputIt> {
|
||||
return vformat_to_n(out, n, fmt, make_format_args(args...));
|
||||
return vformat_to_n(out, n, fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
/** Returns the number of chars in the output of ``format(fmt, args...)``. */
|
||||
template <typename... T>
|
||||
inline auto formatted_size(format_string<T...> fmt, T&&... args) -> size_t {
|
||||
auto buf = detail::counting_buffer<>();
|
||||
detail::vformat_to(buf, string_view(fmt), make_format_args(args...));
|
||||
detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...));
|
||||
return buf.count();
|
||||
}
|
||||
|
||||
@ -2874,7 +2874,7 @@ FMT_API void vprint(std::FILE*, string_view, format_args);
|
||||
*/
|
||||
template <typename... T>
|
||||
inline void print(format_string<T...> fmt, T&&... args) {
|
||||
const auto& vargs = make_format_args(args...);
|
||||
const auto& vargs = fmt::make_format_args(args...);
|
||||
return detail::is_utf8() ? vprint(fmt, vargs)
|
||||
: detail::vprint_mojibake(stdout, fmt, vargs);
|
||||
}
|
||||
@ -2891,7 +2891,7 @@ inline void print(format_string<T...> fmt, T&&... args) {
|
||||
*/
|
||||
template <typename... T>
|
||||
inline void print(std::FILE* f, format_string<T...> fmt, T&&... args) {
|
||||
const auto& vargs = make_format_args(args...);
|
||||
const auto& vargs = fmt::make_format_args(args...);
|
||||
return detail::is_utf8() ? vprint(f, fmt, vargs)
|
||||
: detail::vprint_mojibake(f, fmt, vargs);
|
||||
}
|
||||
|
@ -846,3 +846,24 @@ struct disabled_rvalue_conversion {
|
||||
TEST(core_test, disabled_rvalue_conversion) {
|
||||
EXPECT_EQ("foo", fmt::format("{}", disabled_rvalue_conversion()));
|
||||
}
|
||||
|
||||
namespace adl_test {
|
||||
template <typename... T> void make_format_args(const T&...) = delete;
|
||||
|
||||
struct string : std::string {};
|
||||
} // namespace adl_test
|
||||
|
||||
// Test that formatting functions compile when make_format_args is found by ADL.
|
||||
TEST(core_test, adl) {
|
||||
// Only check compilation and don't run the code to avoid polluting the output
|
||||
// and since the output is tested elsewhere.
|
||||
if (fmt::detail::const_check(true)) return;
|
||||
auto s = adl_test::string();
|
||||
char buf[10];
|
||||
fmt::format("{}", s);
|
||||
fmt::format_to(buf, "{}", s);
|
||||
fmt::format_to_n(buf, 10, "{}", s);
|
||||
fmt::formatted_size("{}", s);
|
||||
fmt::print("{}", s);
|
||||
fmt::print(stdout, "{}", s);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user