doc: add description about ordered_type_config

This commit is contained in:
ToruNiina
2024-08-10 02:10:54 +09:00
parent fcb1d3d7e5
commit 9b914db23d
4 changed files with 48 additions and 4 deletions

View File

@@ -495,10 +495,20 @@ std::cout << toml::format(output) << std::endl;
`toml::value`が持つ型の多く、`integer_type``array_type`などは`type_config`型を変更することで変更可能です。
よくある例として、値を追加した順序を保つ`map`型である`ordered_map`を使うというものがあります。
toml11は`toml::ordered_map`を使用する`type_config`型として、`toml::ordered_type_config`を提供しています。
```cpp
const toml::ordered_value input = toml::parse<toml::ordered_type_config>("input.toml");
```
ここで、`toml::ordered_value``toml::basic_value<toml::ordered_type_config>`のエイリアスです。
ただし、`toml::value``std::unordered_map`を使用しているため、一度`toml::ordered_value`から`toml::value`に変換してしまうと、順序は失われてしまうことに注意してください。
[`examples`ディレクトリ](https://github.com/ToruNiina/toml11/tree/main/examples)には、
多倍長整数を使用する場合やコンテナを変更する場合、ユニコードを正規化する場合などの複雑な使用例を用意しています。
そのような状況での実装例として参照してください。
`type_config`を実装する際の例として参照してください。
## Examples