mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 23:44:01 +01:00
ircd::util: Add util for template based nothrow overloading.
This commit is contained in:
parent
88a15924ed
commit
6674648590
1 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue