arg_router
1.4.0
C++ command line argument parsing and routing
|
#include <arg_router/utility/compile_time_optional.hpp>
Public Types | |
using | value_type = T |
Public Member Functions | |
constexpr | compile_time_optional (value_type val) noexcept |
constexpr | operator bool () const |
constexpr const value_type * | operator-> () const noexcept |
constexpr const value_type & | operator* () const noexcept |
value_type * | operator-> () noexcept |
value_type & | operator* () noexcept |
Static Public Attributes | |
constexpr static bool | empty = false |
Compile-time equivalent of std::optional
.
std::optional
can be used in compile-time expressions, but not when used as a argument, this class can do that but comes with severe runtime limitations due to it.
An empty optional cannot be created and then populated later, nor cleared, as that state is a part of its template parameters (a void
type is an empty compile_time_optional).
Like std::optional
references cannot be stored internally, but it can use a std::reference_wrapper
. Unlike std::optional
this type has a specialisation that makes the std::reference_wrapper
access transparent (i.e. you don't need to dereference twice).
std::reference_wrapper
specialisation is not constexprT | Value type |
Definition at line 29 of file compile_time_optional.hpp.
using arg_router::utility::compile_time_optional< T >::value_type = T |
Value type.
Definition at line 33 of file compile_time_optional.hpp.
|
inlineexplicitconstexprnoexcept |
Constructor.
val | Value to copy into the optional |
Definition at line 42 of file compile_time_optional.hpp.
|
inlineexplicitconstexpr |
Implicit bool conversion operator.
Definition at line 48 of file compile_time_optional.hpp.
|
inlineconstexprnoexcept |
Dereference operator.
Definition at line 62 of file compile_time_optional.hpp.
|
inlinenoexcept |
Non-const overload.
Definition at line 76 of file compile_time_optional.hpp.
|
inlineconstexprnoexcept |
Dereference to member operator.
Definition at line 55 of file compile_time_optional.hpp.
|
inlinenoexcept |
Non-const overload.
Definition at line 69 of file compile_time_optional.hpp.
|
staticconstexpr |
True if empty.
Definition at line 36 of file compile_time_optional.hpp.