Graphviz 13.0.0~dev.20250308.2027
Loading...
Searching...
No Matches
optional.h File Reference

C analog of C++’s std::optional More...

#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for optional.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  optional_double_t
 a container that may or may not contain a double value More...
 

Functions

static void optional_double_set (optional_double_t *me, double value)
 
static double optional_double_value_or (optional_double_t me, double fallback)
 

Function Documentation

◆ optional_double_set()

static void optional_double_set ( optional_double_t me,
double  value 
)
inlinestatic

set the value of an optional

This utility function is intended to avoid the easy typo of setting the value while forgetting to set the has_value member.

Parameters
meThe optional whose value to set
valueThe value to assign

Definition at line 23 of file optional.h.

References optional_double_t::has_value, NULL, and optional_double_t::value.

Referenced by svg_size().

Here is the caller graph for this function:

◆ optional_double_value_or()

static double optional_double_value_or ( optional_double_t  me,
double  fallback 
)
inlinestatic

get the value of an optional or a given value if the optional is empty

Parameters
meThe optional whose value to retrieve
fallbackThe value to return if the optional is empty
Returns
Value of the optional or fallback if it was empty

Definition at line 34 of file optional.h.

References optional_double_t::has_value, and optional_double_t::value.

Referenced by svg_size().

Here is the caller graph for this function: