I\'m testing out user defined literals. I want to make _fac
return the factorial of the number.
Having it call a constexpr
function works,
@Pubby. The easy way to digest the char non-type parameter pack is to cature it into an initializer list for a string. Then you can use atoi, atof, etc:
#include
template
int
operator "" _suffix()
{
const char str[]{Chars..., '\0'};
return atoi(str);
}
int
main()
{
std::cout << 12345_suffix << std::endl;
}
Remember to tack on a null character for the C-style functions.