Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cassert>
- #define auto_assert(...) \
- [](auto expression) \
- { \
- if constexpr (noexcept(expression())) \
- { static_assert(expression()); } \
- else \
- { assert(expression()); } \
- } \
- ([&]{ return __VA_ARGS__; })
- int main(int argc, char **argv)
- {
- auto_assert(1); // -> static_assert(1)
- auto_assert(argc); // -> assert(argc)
- }
Add Comment
Please, Sign In to add comment