Skip to content

Commit eaf8c57

Browse files
committed
Remove deprecated functions
1 parent e33c76a commit eaf8c57

File tree

7 files changed

+28
-94
lines changed

7 files changed

+28
-94
lines changed

ChangeLog.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,16 @@
7474
formatters (https://github.com/fmtlib/fmt/issues/4424,
7575
https://github.com/fmtlib/fmt/pull/4434). Thanks @jeremy-rifkin.
7676
77-
- Removed deprecated `basic_format_args::parse_context_type` and
77+
- Removed the deprecated `has_formatter` trait. Use `is_formattable` instead.
78+
79+
- Removed the deprecated `basic_format_args::parse_context_type`,
7880
`basic_format_args::formatter_type` and similar aliases in context types.
7981
80-
- Removed deprecated `has_formatter`. Use `is_formattable` instead.
82+
- Removed the deprecated wide stream overload of `fmt::printf` and deprecated
83+
wide overloads of `fmt::fprintf` and `fmt::sprintf`.
84+
85+
- Removed the deprecated wide stream overloads of `fmt::print` that take text
86+
styles.
8187
8288
- Removed legacy `is_*char` traits.
8389

doc/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ if an argument type doesn't match its format specification.
674674

675675
::: printf(string_view, const T&...)
676676

677-
::: fprintf(std::FILE*, const S&, const T&...)
677+
::: fprintf(std::FILE*, string_view, const T&...)
678678

679-
::: sprintf(const S&, const T&...)
679+
::: sprintf(string_view, const T&...)
680680

681681
<a id="xchar-api"></a>
682682
## Wide Strings

include/fmt/chrono.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -513,19 +513,7 @@ struct time_zone {
513513
template <typename... T> auto current_zone(T...) -> time_zone* {
514514
return nullptr;
515515
}
516-
517-
template <typename... T> void _tzset(T...) {}
518516
} // namespace tz
519-
520-
// DEPRECATED!
521-
inline void tzset_once() {
522-
static bool init = []() {
523-
using namespace tz;
524-
_tzset();
525-
return false;
526-
}();
527-
ignore_unused(init);
528-
}
529517
} // namespace detail
530518

531519
FMT_BEGIN_EXPORT

include/fmt/format-inl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ template <typename Locale> auto locale_ref::get() const -> Locale {
7575

7676
namespace detail {
7777

78-
// DEPRECATED!
79-
FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
80-
fmt::assert_fail(file, line, message);
81-
}
82-
8378
FMT_FUNC void format_error_code(detail::buffer<char>& out, int error_code,
8479
string_view message) noexcept {
8580
// Report error code making sure that the output fits into

include/fmt/printf.h

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
FMT_BEGIN_NAMESPACE
1919
FMT_BEGIN_EXPORT
2020

21-
template <typename T> struct printf_formatter {
22-
printf_formatter() = delete;
23-
};
24-
2521
template <typename Char> class basic_printf_context {
2622
private:
2723
basic_appender<Char> out_;
@@ -33,8 +29,6 @@ template <typename Char> class basic_printf_context {
3329

3430
public:
3531
using char_type = Char;
36-
using parse_context_type = parse_context<Char>;
37-
template <typename T> using formatter_type = printf_formatter<T>;
3832
enum { builtin_types = 1 };
3933

4034
/// Constructs a `printf_context` object. References to the arguments are
@@ -74,7 +68,7 @@ inline auto find<false, char>(const char* first, const char* last, char value,
7468

7569
// Checks if a value fits in int - used to avoid warnings about comparing
7670
// signed and unsigned integers.
77-
template <bool IsSigned> struct int_checker {
71+
template <bool IS_SIGNED> struct int_checker {
7872
template <typename T> static auto fits_in_int(T value) -> bool {
7973
return value <= to_unsigned(max_value<int>());
8074
}
@@ -570,15 +564,19 @@ inline auto vsprintf(basic_string_view<Char> fmt,
570564
*
571565
* std::string message = fmt::sprintf("The answer is %d", 42);
572566
*/
573-
template <typename S, typename... T, typename Char = detail::char_t<S>>
574-
inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
575-
return vsprintf(detail::to_string_view(fmt),
576-
fmt::make_format_args<basic_printf_context<Char>>(args...));
567+
template <typename... T>
568+
inline auto sprintf(string_view fmt, const T&... args) -> std::string {
569+
return vsprintf(fmt, make_printf_args(args...));
570+
}
571+
template <typename... T>
572+
FMT_DEPRECATED auto sprintf(basic_string_view<wchar_t> fmt, const T&... args)
573+
-> std::wstring {
574+
return vsprintf(fmt, make_printf_args<wchar_t>(args...));
577575
}
578576

579577
template <typename Char>
580-
inline auto vfprintf(std::FILE* f, basic_string_view<Char> fmt,
581-
typename vprintf_args<Char>::type args) -> int {
578+
auto vfprintf(std::FILE* f, basic_string_view<Char> fmt,
579+
typename vprintf_args<Char>::type args) -> int {
582580
auto buf = basic_memory_buffer<Char>();
583581
detail::vprintf(buf, fmt, args);
584582
size_t size = buf.size();
@@ -595,17 +593,14 @@ inline auto vfprintf(std::FILE* f, basic_string_view<Char> fmt,
595593
*
596594
* fmt::fprintf(stderr, "Don't %s!", "panic");
597595
*/
598-
template <typename S, typename... T, typename Char = detail::char_t<S>>
599-
inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
600-
return vfprintf(f, detail::to_string_view(fmt),
601-
make_printf_args<Char>(args...));
596+
template <typename... T>
597+
inline auto fprintf(std::FILE* f, string_view fmt, const T&... args) -> int {
598+
return vfprintf(f, fmt, make_printf_args(args...));
602599
}
603-
604-
template <typename Char>
605-
FMT_DEPRECATED inline auto vprintf(basic_string_view<Char> fmt,
606-
typename vprintf_args<Char>::type args)
607-
-> int {
608-
return vfprintf(stdout, fmt, args);
600+
template <typename... T>
601+
FMT_DEPRECATED auto fprintf(std::FILE* f, basic_string_view<wchar_t> fmt,
602+
const T&... args) -> int {
603+
return vfprintf(f, fmt, make_printf_args<wchar_t>(args...));
609604
}
610605

611606
/**
@@ -620,11 +615,6 @@ template <typename... T>
620615
inline auto printf(string_view fmt, const T&... args) -> int {
621616
return vfprintf(stdout, fmt, make_printf_args(args...));
622617
}
623-
template <typename... T>
624-
FMT_DEPRECATED inline auto printf(basic_string_view<wchar_t> fmt,
625-
const T&... args) -> int {
626-
return vfprintf(stdout, fmt, make_printf_args<wchar_t>(args...));
627-
}
628618

629619
FMT_END_EXPORT
630620
FMT_END_NAMESPACE

include/fmt/xchar.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,6 @@ inline auto format(text_style ts, wformat_string<T...> fmt, T&&... args)
330330
return fmt::vformat(ts, fmt, fmt::make_wformat_args(args...));
331331
}
332332

333-
template <typename... T>
334-
FMT_DEPRECATED void print(std::FILE* f, text_style ts, wformat_string<T...> fmt,
335-
const T&... args) {
336-
vprint(f, ts, fmt, fmt::make_wformat_args(args...));
337-
}
338-
339-
template <typename... T>
340-
FMT_DEPRECATED void print(text_style ts, wformat_string<T...> fmt,
341-
const T&... args) {
342-
return print(stdout, ts, fmt, args...);
343-
}
344-
345333
inline void vprint(std::wostream& os, wstring_view fmt, wformat_args args) {
346334
auto buffer = basic_memory_buffer<wchar_t>();
347335
detail::vformat_to(buffer, fmt, args);

test/printf-test.cc

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ static std::string make_positional(fmt::string_view format) {
3232
return s;
3333
}
3434

35-
static std::wstring make_positional(fmt::basic_string_view<wchar_t> format) {
36-
std::wstring s(format.data(), format.size());
37-
s.replace(s.find(L'%'), 1, L"%1$");
38-
return s;
39-
}
40-
4135
// A wrapper around fmt::sprintf to workaround bogus warnings about invalid
4236
// format strings in MSVC.
4337
template <typename... Args>
@@ -57,7 +51,6 @@ std::wstring test_sprintf(fmt::basic_string_view<wchar_t> format,
5751

5852
TEST(printf_test, no_args) {
5953
EXPECT_EQ("test", test_sprintf("test"));
60-
EXPECT_EQ(L"test", fmt::sprintf(L"test"));
6154
}
6255

6356
TEST(printf_test, escape) {
@@ -66,11 +59,6 @@ TEST(printf_test, escape) {
6659
EXPECT_EQ("% after", test_sprintf("%% after"));
6760
EXPECT_EQ("before % after", test_sprintf("before %% after"));
6861
EXPECT_EQ("%s", test_sprintf("%%s"));
69-
EXPECT_EQ(L"%", fmt::sprintf(L"%%"));
70-
EXPECT_EQ(L"before %", fmt::sprintf(L"before %%"));
71-
EXPECT_EQ(L"% after", fmt::sprintf(L"%% after"));
72-
EXPECT_EQ(L"before % after", fmt::sprintf(L"before %% after"));
73-
EXPECT_EQ(L"%s", fmt::sprintf(L"%%s"));
7462
}
7563

7664
TEST(printf_test, positional_args) {
@@ -467,20 +455,13 @@ TEST(printf_test, char) {
467455
EXPECT_PRINTF("x", "%c", 'x');
468456
int max = max_value<int>();
469457
EXPECT_PRINTF(fmt::format("{}", static_cast<char>(max)), "%c", max);
470-
// EXPECT_PRINTF("x", "%lc", L'x');
471-
EXPECT_PRINTF(L"x", L"%c", L'x');
472-
EXPECT_PRINTF(fmt::format(L"{}", static_cast<wchar_t>(max)), L"%c", max);
473458
}
474459

475460
TEST(printf_test, string) {
476461
EXPECT_PRINTF("abc", "%s", "abc");
477462
const char* null_str = nullptr;
478463
EXPECT_PRINTF("(null)", "%s", null_str);
479464
EXPECT_PRINTF(" (null)", "%10s", null_str);
480-
EXPECT_PRINTF(L"abc", L"%s", L"abc");
481-
const wchar_t* null_wstr = nullptr;
482-
EXPECT_PRINTF(L"(null)", L"%s", null_wstr);
483-
EXPECT_PRINTF(L" (null)", L"%10s", null_wstr);
484465
}
485466

486467
TEST(printf_test, pointer) {
@@ -494,16 +475,6 @@ TEST(printf_test, pointer) {
494475
EXPECT_PRINTF(fmt::format("{:p}", s), "%p", s);
495476
const char* null_str = nullptr;
496477
EXPECT_PRINTF("(nil)", "%p", null_str);
497-
498-
p = &n;
499-
EXPECT_PRINTF(fmt::format(L"{}", p), L"%p", p);
500-
p = nullptr;
501-
EXPECT_PRINTF(L"(nil)", L"%p", p);
502-
EXPECT_PRINTF(L" (nil)", L"%10p", p);
503-
const wchar_t* w = L"test";
504-
EXPECT_PRINTF(fmt::format(L"{:p}", w), L"%p", w);
505-
const wchar_t* null_wstr = nullptr;
506-
EXPECT_PRINTF(L"(nil)", L"%p", null_wstr);
507478
}
508479

509480
enum test_enum { answer = 42 };
@@ -531,10 +502,6 @@ TEST(printf_test, printf_error) {
531502
}
532503
#endif
533504

534-
TEST(printf_test, wide_string) {
535-
EXPECT_EQ(L"abc", fmt::sprintf(L"%s", L"abc"));
536-
}
537-
538505
TEST(printf_test, vprintf) {
539506
int n = 42;
540507
auto store = fmt::make_format_args<fmt::printf_context>(n);

0 commit comments

Comments
 (0)