Is your feature request related to a problem? Please describe.
I'd like a way to get nodes and sub tables in an optional without using get and checking for nullptr.
Describe the solution you'd like
A function possibly named get_optional that is similiar to value except which operates over tables and arrays and places the subnode inside an optional. For example, if we had a toml:
[outer.inner]
x=5
Then, toml.get_optional<toml::table>("inner") should return std::optional<toml::table> with the inner table as it's value.
This is what node views are for - chain them together to reduce verbosity, e.g. toml["outer"]["inner"]["x"] is safe even if outer didn't exist (it will just result in a null view).
Is your feature request related to a problem? Please describe.
I'd like a way to get nodes and sub tables in an optional without using
get
and checking for nullptr.Describe the solution you'd like
A function possibly named
get_optional
that is similiar tovalue
except which operates over tables and arrays and places the subnode inside an optional. For example, if we had a toml:Then,
toml.get_optional<toml::table>("inner")
should returnstd::optional<toml::table>
with the inner table as it's value.