User defined compile time formatted message
Solution 1:
This isn't an answer but I unfortunately don't have enough reputation to leave this as a comment.
I'm just making an educated guess here (still learning A LOT at the moment), but I believe it would be possible using a variadic template function and constexpr/consteval specifiers. If I understand it correctly, your TemplateParameterValue
would have to be a constexpr value and your TemplateCall<TemplateParameterValue> ()
could be a consteval function that produces your constexpr value. You could then pass this constexpr value into your compile_time_printf()
function and get it to do what you want with a consteval specifier as well since it would be an immediate function in this context anyways.
I've read somewhere before that compile time templates hate string literals (I don't know if that's changed or not) but I'm positive you could get around that with the template taking in a std::string_view
because I've personally done that in a current project and haven't run into any issues yet. The only thing is, I don't believe printf() has constexpr support, so you'd have to roll your own compile time parser and the like.
This is just off the assumption that you're trying to verify valid input and issue a warning at compile time if it isn't. Again, this is just the best insight I can give at this moment in time - hopefully someone with more experience can give you a more proper answer and best of luck! =D