|
Graphviz 14.1.4~dev.20260320.0055
|
C analog of C++’s std::optional
More...
#include <assert.h>#include <stdbool.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>Go to the source code of this file.
Macros | |
| #define | OPTIONAL(type) |
| a container that may or may not contain a value | |
| #define | OPTIONAL_SET(me, value) |
| #define | OPTIONAL_VALUE(me) |
| #define | OPTIONAL_VALUE_OR(me, fallback) ((me).has_value ? (me).value_ : (fallback)) |
| #define OPTIONAL | ( | type | ) |
Definition at line 13 of file optional.h.
| #define OPTIONAL_SET | ( | me, | |
| value | |||
| ) |
set the value of an optional
This utility macro is intended to avoid the easy typo of setting the value while forgetting to set the has_value member.
| me | The optional whose value to set |
| value | The value to assign |
Definition at line 26 of file optional.h.
| #define OPTIONAL_VALUE | ( | me | ) |
get the value of an optional
The caller must know the optional has a value before calling this.
| me | The optional whose value to retrieve |
Definition at line 39 of file optional.h.
| #define OPTIONAL_VALUE_OR | ( | me, | |
| fallback | |||
| ) | ((me).has_value ? (me).value_ : (fallback)) |
get the value of an optional or a given value if the optional is empty
| me | The optional whose value to retrieve |
| fallback | The value to return if the optional is empty |
fallback if it was empty Definition at line 53 of file optional.h.