Traits for manipulating noexcept
in C++'s type system.
Requires C++17.
namespace mz
{
// has member 'type' as T with the `noexcept` specifier added
//
// ::type will simply be T if T is not a function or
// (possibly cv-qualified) member function pointer type.
template <typename T>
struct add_noexcept;
// type alias for directly unpacking add_noexcept
// (in the same vein as std::add_const / std::add_const_t, etc.)
template <typename T>
using add_noexcept_t = typename add_noexcept<T>::type;
// has member 'type' as T with the `noexcept` specifier removed
//
// ::type will simply be T if T is not a function or
// (possibly cv-qualified) member function pointer type.
template <typename T>
struct remove_noexcept;
// type alias for directly unpacking remove_noexcept
// (in the same vein as std::remove_const / std::remove_const_t, etc.)
template <typename T>
using remove_noexcept_t = typename remove_noexcept<T>::type;
// has member 'value' indicating if T was a function
// or member function pointer type with the noexcept specifier present.
template <typename T>
struct is_noexcept;
// variable template containing the value of is_noexcept
// (in the same vein as std::is_const / std::is_const_v, etc.)
template <typename T>
inline constexpr bool is_noexcept_v = is_noexcept<T>::value;
}
The library is a single header so the easiest way to use it is to drop noexcept.hpp somewhere in your project.
Alternatively you can add include
to your include paths then #include <mz/noexcept.hpp>
There is also support for use as a meson.build
subproject.
MIT. See LICENSE.
There are three ways you can contribute:
- Reporting bug or making feature requests here
- Opening a pull request (
⚠️ caveat - see below) - Becoming a sponsor ❤️
This project is an implementation of a C++ library proposal I'm in the process of
putting together, with the intent of having these traits become part of the standard's
<type_traits>
library. You can read the paper here.