OpenVPN 3 Core Library
|
CRTP type designed to allow creation of strong types based on intrinsics. More...
#include <intrinsic_type.hpp>
Public Types | |
using | value_type = T |
Public Member Functions | |
constexpr | IntrinsicType (value_type v=value_type()) noexcept |
Constructs an IntrinsicType object. | |
BaseT & | operator= (value_type v) |
Assignment operator from value_type. | |
BaseT & | operator= (BaseT arg) noexcept |
Assignment operator from BaseT. | |
template<typename = std::enable_if_t<std::is_integral_v<T>>> | |
constexpr BaseT & | operator|= (BaseT arg) noexcept |
Bitwise OR assignment operator. | |
template<typename = std::enable_if_t<std::is_integral_v<T>>> | |
constexpr BaseT & | operator&= (BaseT arg) noexcept |
Bitwise AND assignment operator. | |
constexpr value_type | get () const noexcept |
Getter for the underlying value. | |
constexpr | operator value_type () const noexcept |
Conversion operator to value_type. | |
Private Member Functions | |
BaseT & | CrtpBase () noexcept |
Helper function to perform CRTP cast. | |
const BaseT & | CrtpBase () const noexcept |
Const version of helper function to perform CRTP cast. | |
Private Attributes | |
value_type | mValue |
Friends | |
constexpr bool | operator== (const BaseT lhs, const BaseT rhs) noexcept |
Equality operator - class friend. | |
CRTP type designed to allow creation of strong types based on intrinsics.
BaseT | The final type name |
T | The value type |
The IntrinsicType template struct is designed to encapsulate a value of type T and provide a set of operations for manipulating this value. The struct uses the Curiously Recurring Template Pattern (CRTP) to enable static polymorphism, where BaseT is the derived type that inherits from IntrinsicType.
This enables an arithmetic type to be essentially used as a base type for a new strong type, which can be used to enforce type safety and prevent accidental misuse of the underlying value. The struct provides a set of operators for bitwise operations, and could be extended to provide additional operators as needed.
Definition at line 33 of file intrinsic_type.hpp.
using openvpn::IntrinsicType< BaseT, T, typename >::value_type = T |
Definition at line 35 of file intrinsic_type.hpp.
|
inlineexplicitconstexprnoexcept |
Constructs an IntrinsicType object.
v | The value to initialize the object with |
Definition at line 42 of file intrinsic_type.hpp.
|
inlineprivatenoexcept |
Const version of helper function to perform CRTP cast.
Definition at line 138 of file intrinsic_type.hpp.
|
inlineprivatenoexcept |
Helper function to perform CRTP cast.
Definition at line 129 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Getter for the underlying value.
Definition at line 110 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Conversion operator to value_type.
Definition at line 119 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Bitwise AND assignment operator.
arg | The object to AND with |
Definition at line 100 of file intrinsic_type.hpp.
|
inlinenoexcept |
Assignment operator from BaseT.
arg | The object to assign from |
Definition at line 72 of file intrinsic_type.hpp.
|
inline |
Assignment operator from value_type.
v | The value to assign |
Definition at line 50 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Bitwise OR assignment operator.
arg | The object to OR with |
Definition at line 86 of file intrinsic_type.hpp.
|
friend |
Equality operator - class friend.
lhs | Left argument |
rhs | Right argument |
Definition at line 62 of file intrinsic_type.hpp.
|
private |
Definition at line 144 of file intrinsic_type.hpp.