stlab-enum-ops 1.0.0
Type-safe operators for enums
Loading...
Searching...
No Matches
enum_ops.hpp File Reference

Typesafe operators for enum types enabled via opt-in customization points. More...

#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  stlab
 The stlab namespace.

Functions

auto stlab::stlab_enable_bitmask_enum (...) -> std::false_type
auto stlab::stlab_enable_arithmetic_enum (...) -> std::false_type
template<class T>
constexpr auto operator& (T lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T >
 Bitwise AND for bitmask-enabled enums; returns the same enum type.
template<class T>
constexpr auto operator~ (T a) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T >
 Bitwise NOT for bitmask-enabled enums; returns the same enum type.
template<class T>
constexpr auto operator| (T lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T >
 Bitwise OR for bitmask-enabled enums.
template<class T>
constexpr auto operator^ (T lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T >
 Bitwise XOR for bitmask-enabled enums.
template<class T>
constexpr auto operator<< (T lhs, std::size_t rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T >
 Left shift for bitmask-enabled enums.
template<class T>
constexpr auto operator>> (T lhs, std::size_t rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T >
 Right shift for bitmask-enabled enums.
template<class T>
constexpr auto operator^= (T &lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T & >
 XOR-assign for bitmask-enabled enums.
template<class T>
constexpr auto operator&= (T &lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T & >
 AND-assign for bitmask-enabled enums.
template<class T>
constexpr auto operator|= (T &lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T & >
 OR-assign for bitmask-enabled enums.
template<class T>
constexpr auto operator<<= (T &lhs, std::size_t rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T & >
 Left shift-assign for bitmask-enabled enums.
template<class T>
constexpr auto operator>>= (T &lhs, std::size_t rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T >, T & >
 Right shift-assign for bitmask-enabled enums.
template<class T, class U>
constexpr auto operator- (T lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_bitmask< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T >
 Subtracts a value convertible to the underlying type from a bitmask-enabled enum.
template<class T>
constexpr auto operator+ (T a) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T >
 Unary plus for arithmetic-enabled enums.
template<class T>
constexpr auto operator- (T a) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T >
 Unary minus for arithmetic-enabled enums.
template<class T>
constexpr auto operator+ (T lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T >
 Addition for arithmetic-enabled enums.
template<class T>
constexpr auto operator- (T lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T >
 Subtraction for arithmetic-enabled enums.
template<class T, class U>
constexpr auto operator* (T lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T >
 Multiplication by a value convertible to the enum's underlying type.
template<class U, class T>
constexpr auto operator* (U lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T >
 Multiplication with the scalar on the left-hand side.
template<class T, class U>
constexpr auto operator/ (T lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T >
 Division by a value convertible to the enum's underlying type.
template<class T, class U>
constexpr auto operator% (T lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T >
 Modulo by a value convertible to the enum's underlying type.
template<class T>
constexpr auto operator+= (T &lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T & >
 Addition assignment for arithmetic-enabled enums.
template<class T>
constexpr auto operator-= (T &lhs, T rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T & >
 Subtraction assignment for arithmetic-enabled enums.
template<class T, class U>
constexpr auto operator*= (T &lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T & >
 Multiplication assignment by a value convertible to the enum's underlying type.
template<class T, class U>
constexpr auto operator/= (T &lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T & >
 Division assignment by a value convertible to the enum's underlying type.
template<class T, class U>
constexpr auto operator%= (T &lhs, U rhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T > &&stlab::implementation::is_convertible_to_underlying< U, T >::value, T & >
 Modulo assignment by a value convertible to the enum's underlying type.
template<class T>
constexpr auto operator++ (T &lhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T & >
 Prefix increment for arithmetic-enabled enums.
template<class T>
constexpr auto operator++ (T &lhs, int) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T >
 Postfix increment for arithmetic-enabled enums.
template<class T>
constexpr auto operator-- (T &lhs) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T & >
 Prefix decrement for arithmetic-enabled enums.
template<class T>
constexpr auto operator-- (T &lhs, int) -> std::enable_if_t< stlab::implementation::has_enabled_arithmetic< T >, T >
 Postfix decrement for arithmetic-enabled enums.
template<class T>
constexpr auto operator== (T lhs, std::nullptr_t) -> std::enable_if_t<(stlab::implementation::has_enabled_bitmask< T >||stlab::implementation::has_enabled_arithmetic< T >) &&!stlab::implementation::is_convertible_to_underlying< T, T >::value, bool >
 Equality with nullptr for bitmask or arithmetic scoped enums; true when the value is zero.
template<class T>
constexpr auto operator== (std::nullptr_t, T rhs) -> std::enable_if_t<(stlab::implementation::has_enabled_bitmask< T >||stlab::implementation::has_enabled_arithmetic< T >) &&!stlab::implementation::is_convertible_to_underlying< T, T >::value, bool >
 Equality with nullptr for bitmask or arithmetic scoped enums; true when the value is zero.
template<class T>
constexpr auto operator!= (T lhs, std::nullptr_t rhs) -> std::enable_if_t<(stlab::implementation::has_enabled_bitmask< T >||stlab::implementation::has_enabled_arithmetic< T >) &&!stlab::implementation::is_convertible_to_underlying< T, T >::value, bool >
 Inequality with nullptr for bitmask or arithmetic scoped enums.
template<class T>
constexpr auto operator!= (std::nullptr_t lhs, T rhs) -> std::enable_if_t<(stlab::implementation::has_enabled_bitmask< T >||stlab::implementation::has_enabled_arithmetic< T >) &&!stlab::implementation::is_convertible_to_underlying< T, T >::value, bool >
 Inequality with nullptr for bitmask or arithmetic scoped enums.
template<class T>
constexpr auto operator! (T lhs) -> stlab::implementation::enable_if_bitmask_or_arithmetic< T, bool >
 Logical NOT for bitmask or arithmetic enums; true when the value converts to false.

Detailed Description

Typesafe operators for enum types enabled via opt-in customization points.