diff --git a/include/fmt/core.h b/include/fmt/core.h index 4cc47229..79b9298a 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1817,15 +1817,14 @@ class format_arg_store public: template - FMT_CONSTEXPR FMT_INLINE format_arg_store(T&&... args) + FMT_CONSTEXPR FMT_INLINE format_arg_store(T&... args) : #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 basic_format_args(*this), #endif data_{detail::make_arg< is_packed, Context, - detail::mapped_type_constant, Context>::value>( - FMT_FORWARD(args))...} { + detail::mapped_type_constant::value>(args)...} { detail::init_named_args(data_.named_args(), 0, 0, args...); } }; diff --git a/test/printf-test.cc b/test/printf-test.cc index 02ae433e..9fbab106 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -529,8 +529,9 @@ TEST(printf_test, wide_string) { } TEST(printf_test, vprintf) { - fmt::format_arg_store as{42}; - fmt::basic_format_args args(as); + int n = 42; + auto store = fmt::format_arg_store(n); + auto args = fmt::basic_format_args(store); EXPECT_EQ(fmt::vsprintf("%d", args), "42"); EXPECT_WRITE(stdout, fmt::vprintf("%d", args), "42"); EXPECT_WRITE(stdout, fmt::vfprintf(stdout, "%d", args), "42"); @@ -549,30 +550,10 @@ TEST(printf_test, fixed_large_exponent) { EXPECT_EQ("1000000000000000000000", fmt::sprintf("%.*f", -13, 1e21)); } -TEST(printf_test, vsprintf_make_args_example) { - fmt::format_arg_store as{42, - "something"}; - fmt::basic_format_args args(as); - EXPECT_EQ("[42] something happened", fmt::vsprintf("[%d] %s happened", args)); - auto as2 = fmt::make_printf_args(42, "something"); - fmt::basic_format_args args2(as2); - EXPECT_EQ("[42] something happened", - fmt::vsprintf("[%d] %s happened", args2)); +TEST(printf_test, make_printf_args) { EXPECT_EQ("[42] something happened", fmt::vsprintf("[%d] %s happened", {fmt::make_printf_args(42, "something")})); -} - -TEST(printf_test, vsprintf_make_wargs_example) { - fmt::format_arg_store as{ - 42, L"something"}; - fmt::basic_format_args args(as); - EXPECT_EQ(L"[42] something happened", - fmt::vsprintf(L"[%d] %s happened", args)); - auto as2 = fmt::make_wprintf_args(42, L"something"); - fmt::basic_format_args args2(as2); - EXPECT_EQ(L"[42] something happened", - fmt::vsprintf(L"[%d] %s happened", args2)); EXPECT_EQ(L"[42] something happened", fmt::vsprintf(L"[%d] %s happened", {fmt::make_wprintf_args(42, L"something")})); diff --git a/test/xchar-test.cc b/test/xchar-test.cc index cfdaf76f..fb7aa8c7 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -442,8 +442,8 @@ TEST(locale_test, format) { EXPECT_EQ("1~234~567", fmt::format(loc, "{:L}", 1234567)); EXPECT_EQ("-1~234~567", fmt::format(loc, "{:L}", -1234567)); EXPECT_EQ("-256", fmt::format(loc, "{:L}", -256)); - fmt::format_arg_store as{1234567}; - EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:L}", fmt::format_args(as))); + auto n = 1234567; + EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:L}", fmt::make_format_args(n))); auto s = std::string(); fmt::format_to(std::back_inserter(s), loc, "{:L}", 1234567); EXPECT_EQ("1~234~567", s); @@ -477,9 +477,9 @@ TEST(locale_test, wformat) { EXPECT_EQ(L"1234567", fmt::format(std::locale(), L"{:L}", 1234567)); EXPECT_EQ(L"1~234~567", fmt::format(loc, L"{:L}", 1234567)); using wcontext = fmt::buffer_context; - fmt::format_arg_store as{1234567}; + int n = 1234567; EXPECT_EQ(L"1~234~567", - fmt::vformat(loc, L"{:L}", fmt::basic_format_args(as))); + fmt::vformat(loc, L"{:L}", fmt::make_wformat_args(n))); EXPECT_EQ(L"1234567", fmt::format(std::locale("C"), L"{:L}", 1234567)); auto no_grouping_loc = std::locale(std::locale(), new no_grouping());