mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-25 13:50:05 +00:00
doc #217: add description about C++17 feature
This commit is contained in:
parent
0dcf07b774
commit
2da3b67d02
@ -478,11 +478,16 @@ elements.
|
|||||||
```cpp
|
```cpp
|
||||||
const auto data = toml::parse("example.toml");
|
const auto data = toml::parse("example.toml");
|
||||||
std::cout << "keys in the top-level table are the following: \n";
|
std::cout << "keys in the top-level table are the following: \n";
|
||||||
for(const auto& [k, v] : data.as_table())
|
for(const auto& kv : data.as_table())
|
||||||
|
{
|
||||||
|
std::cout << kv.first << '\n';
|
||||||
|
}
|
||||||
|
for(const auto& [k, v] : data.as_table()) // or in C++17
|
||||||
{
|
{
|
||||||
std::cout << k << '\n';
|
std::cout << k << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const auto& fruits = toml::find(data, "fruits");
|
const auto& fruits = toml::find(data, "fruits");
|
||||||
for(const auto& v : fruits.as_array())
|
for(const auto& v : fruits.as_array())
|
||||||
{
|
{
|
||||||
@ -1169,7 +1174,7 @@ add a comma after the first element (like `[1,]`).
|
|||||||
"[[table]]"_toml; // This is a table that has an array of tables inside.
|
"[[table]]"_toml; // This is a table that has an array of tables inside.
|
||||||
|
|
||||||
"[[1]]"_toml; // This literal is ambiguous.
|
"[[1]]"_toml; // This literal is ambiguous.
|
||||||
// Currently, it becomes a table that has array of table "1".
|
// Currently, it becomes an empty array of table named "1".
|
||||||
"1 = [{}]"_toml; // This is a table that has an array of table named 1.
|
"1 = [{}]"_toml; // This is a table that has an array of table named 1.
|
||||||
"[[1,]]"_toml; // This is an array of arrays.
|
"[[1,]]"_toml; // This is an array of arrays.
|
||||||
"[[1],]"_toml; // ditto.
|
"[[1],]"_toml; // ditto.
|
||||||
|
Loading…
Reference in New Issue
Block a user