mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 06:21:00 +00:00
Fix #2817: add compile-time checking to ostream overloads of fmt::print
This commit is contained in:
parent
3d19be282a
commit
17ba99c1d2
@ -11,6 +11,7 @@
|
||||
#include <ostream>
|
||||
|
||||
#include "format.h"
|
||||
#include "xchar.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
@ -115,7 +116,8 @@ struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
|
||||
|
||||
FMT_MODULE_EXPORT
|
||||
template <typename Char>
|
||||
void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
|
||||
void vprint(std::basic_ostream<Char>& os,
|
||||
basic_string_view<type_identity_t<Char>> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
auto buffer = basic_memory_buffer<Char>();
|
||||
detail::vformat_to(buffer, format_str, args);
|
||||
@ -132,12 +134,17 @@ void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
|
||||
\endrst
|
||||
*/
|
||||
FMT_MODULE_EXPORT
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
void print(std::basic_ostream<Char>& os, const S& format_str, Args&&... args) {
|
||||
vprint(os, to_string_view(format_str),
|
||||
fmt::make_format_args<buffer_context<Char>>(args...));
|
||||
template <typename... Args>
|
||||
void print(std::ostream& os, format_string<Args...> fmt, Args&&... args) {
|
||||
vprint(os, fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
FMT_MODULE_EXPORT
|
||||
template <typename... Args>
|
||||
void print(std::wostream& os, wformat_string<Args...> fmt, Args&&... args) {
|
||||
vprint(os, fmt, fmt::make_wformat_args(args...));
|
||||
}
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_OSTREAM_H_
|
||||
|
Loading…
Reference in New Issue
Block a user