Closed HealthyPear closed 10 months ago
value_or() should do the trick:
toml::table tbl = toml::parse(R"(
[world]
size = ["3 m", "1 m", "1 m"]
)"sv);
std::vector<std::string> size{
tbl["world"][0].value_or("0 m"),
tbl["world"][1].value_or("0 m"),
tbl["world"][2].value_or("0 m")
};
this works but you need to add ["size"]
between ["world"]
and the index
maybe this small example is worth adding to the docs, not sure if I have overlooked it
There is an example of value_or() in the docs already. It's on the main page, under "Working with TOML data".
Anyways, glad it works for you.
There is an example of value_or() in the docs already. It's on the main page, under "Working with TOML data".
I saw that but it refers to a simple string, not to an array which was for me less straightforward (but again, it might be that I am the problem since I never really worked with C++)
Is your feature request related to a problem? Please describe.
I have something like this,
This issue is likely related to the discussion in #45 and it's for sure related to my poor understanding of C++ :)
Describe the solution you'd like
I tried to play a bit like this (nevermind the type prints, I was trying to navigate the API docs),
Is this not possible or am I (very likely) missing something?
Additional context