From 6674648590bdf9996d1c8203b68f8d3059680cd8 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 7 Sep 2016 14:39:05 -0700 Subject: [PATCH] ircd::util: Add util for template based nothrow overloading. --- include/ircd/util.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/ircd/util.h b/include/ircd/util.h index 66017befb..b62eeeec0 100644 --- a/include/ircd/util.h +++ b/include/ircd/util.h @@ -337,6 +337,27 @@ struct _TEST_SIZEOF_; #define IRCD_TEST_SIZEOF(name) \ ircd::util::_TEST_SIZEOF_ _test_; + +/* This is a template alternative to nothrow overloads, which + * allows keeping the function arguments sanitized of the thrownness. + */ + +template +constexpr bool +is_nothrow() +{ + return std::is_same::value; +} + +template +using nothrow_overload = typename std::enable_if(), return_t>::type; + +template +using throw_overload = typename std::enable_if(), return_t>::type; + + } // namespace util } // namespace ircd #endif // __cplusplus