##Error cases:
Error cases:
##Error cases:
Error cases:
This includes changes based on the comments from @Loki Astari @Loki Astari on the previous iteration of this code here here.
This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.
This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.
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');
Compile time checking of printf-like format strings
Inspired by this open ticket on boost, 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.
too 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");
too 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")
mismatch 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');
Inspired by this open ticket on Boost, this seeks to complete the work there.
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 .
Too 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");
Too 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")
Mismatch 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');