Skip to content

Commit

Permalink
Check make_format_args's preconditions (#3080)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: Sam Huang <samestimable2016@gmail.com>
  • Loading branch information
3 people committed Oct 12, 2022
1 parent 1fe4d43 commit fe9f858
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -3403,11 +3403,17 @@ _EXPORT_STD using wformat_args = basic_format_args<wformat_context>;

_EXPORT_STD template <class _Context = format_context, class... _Args>
_NODISCARD auto make_format_args(_Args&&... _Vals) {
static_assert((_Has_formatter<_Args, _Context> && ...),
"Cannot format an argument. To make type T formattable, provide a formatter<T> specialization. "
"See N4917 [format.arg.store]/2 and [formatter.requirements].");
return _Format_arg_store<_Context, _Args...>{_Vals...};
}

_EXPORT_STD template <class... _Args>
_NODISCARD auto make_wformat_args(_Args&&... _Vals) {
static_assert((_Has_formatter<_Args, wformat_context> && ...),
"Cannot format an argument. To make type T formattable, provide a formatter<T> specialization. "
"See N4917 [format.arg.store]/2 and [formatter.requirements].");
return _Format_arg_store<wformat_context, _Args...>{_Vals...};
}

Expand Down

0 comments on commit fe9f858

Please sign in to comment.