From bf992e8f94c38a46fd3bef497e0d6a0c77605e26 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 3 Apr 2020 23:45:45 +0900 Subject: [PATCH] doc: update README for v1-rc1 --- README.md | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3823a0d..4528d21 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ toml11 toml11 is a C++11 (or later) header-only toml parser/encoder depending only on C++ standard library. -- It is compatible to the latest version of [TOML v0.5.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md). -- It optionally supports the [unreleased features](#unreleased-toml-features) in the master branch of toml-lang/toml. +- It is compatible to the latest version of [TOML v1.0.0-rc.1](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v1.0.0-rc.1.md). - It is one of the most TOML standard compliant libraries, tested with [the language agnostic test suite for TOML parsers by BurntSushi](https://github.com/BurntSushi/toml-test). - It shows highly informative error messages. You can see the error messages about invalid files at [CircleCI](https://circleci.com/gh/ToruNiina/toml11). - It has configurable container. You can use any random-access containers and key-value maps as backend containers. @@ -1652,13 +1651,8 @@ not capable of representing a Local Time independent from a specific day. ## Unreleased TOML features -There are some unreleased features in toml-lang/toml:master. -Currently, the following features are available after defining -`TOML11_USE_UNRELEASED_TOML_FEATURES` macro flag. - -To use those features, `#define` `TOML11_USE_UNRELEASED_TOML_FEATURES` before -including `toml.hpp` or pass `-DTOML11_USE_UNRELEASED_TOML_FEATURES` to your -compiler. +Since TOML v1.0.0-rc.1 has been released, those features are now activated by +default. We no longer need to define `TOML11_USE_UNRELEASED_FEATURES`. - Leading zeroes in exponent parts of floats are permitted. - e.g. `1.0e+01`, `5e+05` @@ -1668,10 +1662,10 @@ compiler. - Allow heterogeneous arrays - [toml-lang/toml/PR/676](https://github.com/toml-lang/toml/pull/676) -### Note about heterogeneous arrays +## Note about heterogeneous arrays Although `toml::parse` allows heterogeneous arrays, constructor of `toml::value` -does not. +does not. Here the reason is explained. ```cpp // this won't be compiled @@ -1680,8 +1674,10 @@ toml::value v{ } ``` -There is a workaround for this issue. By explicitly converting values into +There is a workaround for this. By explicitly converting values into `toml::value`, you can initialize `toml::value` with a heterogeneous array. +Also, you can first initialize a `toml::value` with an array and then +`push_back` into it. ```cpp // OK! @@ -1689,6 +1685,17 @@ toml::value v{ toml::value("foo"), toml::value(3.14), toml::value(42), toml::value{1,2,3,4,5}, toml::value{{"key", "value"}} } + +// OK! +toml::value v(toml::array{}); +v.push_back("foo"); +v.push_back(3.14); + +// OK! +toml::array a; +a.push_back("foo"); +a.push_back(3.14); +toml::value v(std::move(a)); ``` The reason why the first example is not allowed is the following. @@ -1717,15 +1724,14 @@ This means that the above C++ code makes constructor's overload resolution ambiguous. So a constructor that allows both "table as an initializer-list" and "heterogeneous array as an initializer-list" cannot be implemented. -Thus, although it is painful, you need to explicitly cast values into -`toml::value` when you initialize heterogeneous array in C++ code. +Thus, although it is painful, we need to explicitly cast values into +`toml::value` when you initialize heterogeneous array in a C++ code. ```cpp -// You need to do this when you want to initialize hetero array. toml::value v{ toml::value("foo"), toml::value(3.14), toml::value(42), toml::value{1,2,3,4,5}, toml::value{{"key", "value"}} -} +}; ``` ## Breaking Changes from v2