Graphviz 13.0.0~dev.20250308.2027
Loading...
Searching...
No Matches
optional.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <assert.h>
7#include <stdbool.h>
8#include <stddef.h>
9
11typedef struct {
12 bool has_value;
13 double value;
15
23static inline void optional_double_set(optional_double_t *me, double value) {
24 assert(me != NULL);
25 me->has_value = true;
26 me->value = value;
27}
28
35 double fallback) {
36 if (me.has_value) {
37 return me.value;
38 }
39 return fallback;
40}
node NULL
Definition grammar.y:163
static void optional_double_set(optional_double_t *me, double value)
Definition optional.h:23
static double optional_double_value_or(optional_double_t me, double fallback)
Definition optional.h:34
a container that may or may not contain a double value
Definition optional.h:11
double value
the value if has_value is true
Definition optional.h:13
bool has_value
does this have a value?
Definition optional.h:12