From b4b35ea33edff3b611206ce6982c2855b9f88597 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Tue, 8 Oct 2019 23:23:53 +0900 Subject: [PATCH] feat: allow 0-prefix exponent if the flag is on If unreleased feature is activated, zero-prefixes in an exponent part of a floating point is allowed. If the flag TOML11_UNRELEASED_TOML_FEATURES is turned on, we don't need to check whether there is a zero prefix in the exponent part that is formatted by a standard library. --- toml/serializer.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/toml/serializer.hpp b/toml/serializer.hpp index f1fa762..44fae97 100644 --- a/toml/serializer.hpp +++ b/toml/serializer.hpp @@ -118,8 +118,14 @@ struct serializer { return token; // there is no exponent part. just return it. } - - // zero-prefix in an exponent is NOT allowed in TOML. +#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES + // Although currently it is not released yet, TOML will allow + // zero-prefix in an exponent part such as 1.234e+01. + // The following code removes the zero prefixes. + // If the feature is activated, the following codes can be skipped. + return token; +#endif + // zero-prefix in an exponent is NOT allowed in TOML v0.5.0. // remove it if it exists. bool sign_exists = false; std::size_t zero_prefix = 0;