0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::util: Add util for template based nothrow overloading.

This commit is contained in:
Jason Volk 2016-09-07 14:39:05 -07:00
parent 88a15924ed
commit 6674648590

View file

@ -337,6 +337,27 @@ struct _TEST_SIZEOF_;
#define IRCD_TEST_SIZEOF(name) \
ircd::util::_TEST_SIZEOF_<sizeof(name)> _test_;
/* This is a template alternative to nothrow overloads, which
* allows keeping the function arguments sanitized of the thrownness.
*/
template<class exception_t>
constexpr bool
is_nothrow()
{
return std::is_same<exception_t, std::nothrow_t>::value;
}
template<class exception_t = std::nothrow_t,
class return_t = bool>
using nothrow_overload = typename std::enable_if<is_nothrow<exception_t>(), return_t>::type;
template<class exception_t,
class return_t = void>
using throw_overload = typename std::enable_if<!is_nothrow<exception_t>(), return_t>::type;
} // namespace util
} // namespace ircd
#endif // __cplusplus