In C with #define
it's easy to concatenates two strings for example:
#define PRINT_DBG(_msg_) print("[DBG]" _msg_)
I was looking and found this exist conststr
Is it possible to link this literals at compile time?
template<typename... Args>
inline void DBG(conststr fmt, Args... args)
{
printf ("[DBG]" fmt, args ...);
}
template<typename... Args>
inline void WRN(conststr fmt, Args... args)
{
printf (""\e[1;31m" [WRN]" fmt + "\e[0m", args ...);
}
As first arg function take const char *
. Any idea?
I found also this implementation, but seems to not work also. https://github.com/akrzemi1/static_string
Purpose:
Example of use. I want to make it work on compile time. For now i use makro for this purpose.
DBG("Some dbg information %s", "23");
WRN("Some wrn information %s", "44");