Compile time checking of printf-like format strings
Inspired by this open ticket on boostBoost, this seeks to complete the work there.
Code:
This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.
Here is the below code running on ideone.
Any suggestions on this would be greatly appreciated.
tooToo few arguments:
main.cpp:285:84: error: expression ‘<throw-expression>’ is not a constant-expression
: throw std::logic_error("too few arguments for provided format string");
main.cpp:285:84: error: expression ‘<throw-expression>’ is not a constant-expression
: throw std::logic_error("too few arguments for provided format string");
tooToo many arguments:
main.cpp:257:87: error: expression ‘<throw-expression>’ is not a constant-expression
throw std::logic_error("too many arguments for provided format string")
main.cpp:257:87: error: expression ‘<throw-expression>’ is not a constant-expression
throw std::logic_error("too many arguments for provided format string")
mismatchMismatch between argument type and format:
main.cpp:29:68: error: expression ‘<throw-expression>’ is not a constant-expression
{ return C != c ? throw std::logic_error("invalid fmt for type") : true; } \
^
main.cpp:33:1: note: in expansion of macro ‘SUPPORTED_TYPE’
SUPPORTED_TYPE(int, 'd');
main.cpp:29:68: error: expression ‘<throw-expression>’ is not a constant-expression
{ return C != c ? throw std::logic_error("invalid fmt for type") : true; } \
^
main.cpp:33:1: note: in expansion of macro ‘SUPPORTED_TYPE’
SUPPORTED_TYPE(int, 'd');