doc: simplity example code a bit

This commit is contained in:
ToruNiina
2021-01-25 17:25:29 +09:00
parent 43183e2ad1
commit d3de136562

View File

@@ -28,6 +28,10 @@ toml11 is a C++11 (or later) header-only toml parser/encoder depending only on C
int main() int main()
{ {
// ```toml
// title = "an example toml file"
// nums = [3, 1, 4, 1, 5]
// ```
auto data = toml::parse("example.toml"); auto data = toml::parse("example.toml");
// find a value with the specified type from a table // find a value with the specified type from a table
@@ -37,9 +41,9 @@ int main()
std::vector<int> nums = toml::find<std::vector<int>>(data, "nums"); std::vector<int> nums = toml::find<std::vector<int>>(data, "nums");
// access with STL-like manner // access with STL-like manner
if(not data.at("a").contains("b")) if(not data.contains("foo"))
{ {
data["a"]["b"] = "c"; data["foo"] = "bar";
} }
// pass a fallback // pass a fallback