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. | |
constexpr BaseT | operator+= (BaseT arg) noexcept |
Add assignment operator. | |
constexpr BaseT | operator-= (BaseT arg) noexcept |
Subtract assignment operator. | |
constexpr BaseT | operator*= (BaseT arg) noexcept |
Multiply assignment operator. | |
constexpr BaseT | operator/= (BaseT arg) noexcept |
Divide assignment operator. | |
constexpr BaseT & | operator|= (BaseT arg) noexcept |
Bitwise OR assignment operator. | |
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 |
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 34 of file intrinsic_type.hpp.
using openvpn::IntrinsicType< BaseT, T >::value_type = T |
Definition at line 36 of file intrinsic_type.hpp.
|
inlineexplicitconstexprnoexcept |
Constructs an IntrinsicType object.
v | The value to initialize the object with |
Definition at line 43 of file intrinsic_type.hpp.
|
inlineprivatenoexcept |
Const version of helper function to perform CRTP cast.
Definition at line 172 of file intrinsic_type.hpp.
|
inlineprivatenoexcept |
Helper function to perform CRTP cast.
Definition at line 163 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Getter for the underlying value.
Definition at line 144 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Conversion operator to value_type.
Definition at line 153 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Bitwise AND assignment operator.
arg | The object to AND with |
Definition at line 133 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Multiply assignment operator.
arg | The object to multiply |
Definition at line 95 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Add assignment operator.
arg | The object to add |
Definition at line 73 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Subtract assignment operator.
arg | The object to subtract |
Definition at line 84 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Divide assignment operator.
arg | The object to divide |
Definition at line 106 of file intrinsic_type.hpp.
|
inlinenoexcept |
Assignment operator from BaseT.
arg | The object to assign from |
Definition at line 62 of file intrinsic_type.hpp.
|
inline |
Assignment operator from value_type.
v | The value to assign |
Definition at line 51 of file intrinsic_type.hpp.
|
inlineconstexprnoexcept |
Bitwise OR assignment operator.
arg | The object to OR with |
Definition at line 119 of file intrinsic_type.hpp.
|
private |
Definition at line 178 of file intrinsic_type.hpp.