Skip to content

AOptional#

Utility wrapper implementing the stack-allocated (fast) optional idiom.

Header:#include <AUI/Common/AOptional.h>
CMake:aui_link(my_target PUBLIC aui::core)

Examples#

examples/7guis/flight_booker/src/main.cpp

7GUIs Flight Booker - Flight Booker.

constexpr auto REGEX_DATE = ctre::match<"([0-9]+)\\.([0-9]+)\\.([0-9]{4})">;

struct DateTextFieldState {
    AProperty<AOptional<system_clock::time_point>> parsed;
};

auto formatDate(system_clock::time_point date) { return "{0:%d}.{0:%m}.{0:%G}"_format(date); }

auto dateTextField(DateTextFieldState& state) {

Public Methods#

valueOr#


template<typename F >
T AOptional::valueOr(F&& alternative)

value or alternative (either value or callback)

Arguments
alternative

valueOrException#


T& AOptional::valueOrException(const char* message = "empty optional")

value or exception


const T& AOptional::valueOrException(const char* message = "empty optional")

value or exception