diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:19:22 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:19:22 +0100 |
commit | 14607b48d21ec9671c848ee4ae567d5fa9128a2c (patch) | |
tree | 08c5d63e46418f2707d83e6de9f2a5d9d7673816 | |
parent | Fix passing multiple params to verify exception (diff) | |
download | mygrate-14607b48d21ec9671c848ee4ae567d5fa9128a2c.tar.bz2 mygrate-14607b48d21ec9671c848ee4ae567d5fa9128a2c.tar.xz mygrate-14607b48d21ec9671c848ee4ae567d5fa9128a2c.zip |
Have verify return its expression, might be useful
-rw-r--r-- | lib/helpers.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/helpers.h b/lib/helpers.h index 17c60dc..45be139 100644 --- a/lib/helpers.h +++ b/lib/helpers.h @@ -15,13 +15,14 @@ namespace MyGrate { return (i >> offset) & ((1U << size) - 1U); } - template<typename X, typename... P> - constexpr inline void - verify(bool expr, P &&... p) + template<typename X, typename R, typename... P> + constexpr inline auto + verify(R expr, P &&... p) { if (!expr) { throw X(std::forward<P>(p)...); } + return expr; } template<typename T> |