From a73d89e9c7aca0851a4908fe8a208a373923857c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 4 Jan 2020 07:11:11 -1000 Subject: [PATCH] Catch invalid uses of fmt::arg --- include/fmt/core.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 5029b673..5f742dd2 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1396,7 +1396,10 @@ template struct named_arg_base { } }; -template struct named_arg : named_arg_base { +struct view {}; + +template +struct named_arg : view, named_arg_base { const T& value; named_arg(basic_string_view name, const T& val) @@ -1414,7 +1417,6 @@ inline void check_format_string(const S&) { template ::value)> void check_format_string(S); -struct view {}; template struct bool_pack; template using all_true = @@ -1443,13 +1445,8 @@ typename buffer_context::iterator vformat_to( /** \rst - Returns a named argument to be used in a formatting function. - - The named argument holds a reference and does not extend the lifetime - of its arguments. - Consequently, a dangling reference can accidentally be created. - The user should take care to only pass this function temporaries when - the named argument is itself a temporary, as per the following example. + Returns a named argument to be used in a formatting function. It should only + be used in a call to a formatting function. **Example**::