Codechange: compile-time validate the string format of IConsolePrint (#11804)

This means we can no longer use runtime picking what string to use.
This commit is contained in:
Patric Stout
2024-01-16 22:04:35 +01:00
committed by GitHub
parent 8b4c5a6269
commit 0b7410d979
3 changed files with 23 additions and 24 deletions

View File

@@ -34,16 +34,15 @@ void IConsolePrint(TextColour colour_code, const std::string &string);
* @param format_string The formatting string to tell what to do with the remaining arguments.
* @param first_arg The first argument to the format.
* @param other_args The other arguments to the format.
* @tparam T The type of formatting parameter.
* @tparam A The type of the first argument.
* @tparam Args The types of the other arguments.
*/
template <typename T, typename A, typename ... Args>
inline void IConsolePrint(TextColour colour_code, const T &format, A first_arg, Args&&... other_args)
template <typename A, typename ... Args>
inline void IConsolePrint(TextColour colour_code, fmt::format_string<A, Args...> format, A first_arg, Args&&... other_args)
{
/* The separate first_arg argument is added to aid overloading.
* Otherwise the calls that do no need formatting will still use this function. */
IConsolePrint(colour_code, fmt::format(format, first_arg, other_args...));
IConsolePrint(colour_code, fmt::format(format, std::forward<A>(first_arg), std::forward<Args>(other_args)...));
}
/* Parser */