From 475ad691d66fbc073d3c3f748c17b33922e22339 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 12 May 2019 00:15:17 +0300 Subject: [PATCH] Add changelog, design, implementation sections --- doc/variant2.adoc | 3 ++ doc/variant2/changelog.adoc | 18 +++++++++++ doc/variant2/design.adoc | 54 ++++++++++++++++++++++++++++++++ doc/variant2/implementation.adoc | 25 +++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 doc/variant2/changelog.adoc create mode 100644 doc/variant2/design.adoc create mode 100644 doc/variant2/implementation.adoc diff --git a/doc/variant2.adoc b/doc/variant2.adoc index 495c446..0ecbe4b 100644 --- a/doc/variant2.adoc +++ b/doc/variant2.adoc @@ -17,6 +17,9 @@ Peter Dimov :leveloffset: +1 include::variant2/overview.adoc[] +include::variant2/changelog.adoc[] +include::variant2/design.adoc[] +include::variant2/implementation.adoc[] include::variant2/reference.adoc[] include::variant2/copyright.adoc[] diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc new file mode 100644 index 0000000..7f7ea55 --- /dev/null +++ b/doc/variant2/changelog.adoc @@ -0,0 +1,18 @@ +//// +Copyright 2019 Peter Dimov + +Distributed under the Boost Software License, Version 1.0. + +See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt +//// + +[#changelog] +# Revision History +:idprefix: changelog_ + +## Changes in 1.71.0 + +After the Boost formal review, the implementation has been +changed to provide the strong exception safety guarantee, +instead of basic. `expected` has been removed, for now. diff --git a/doc/variant2/design.adoc b/doc/variant2/design.adoc new file mode 100644 index 0000000..0950862 --- /dev/null +++ b/doc/variant2/design.adoc @@ -0,0 +1,54 @@ +//// +Copyright 2018, 2019 Peter Dimov + +Distributed under the Boost Software License, Version 1.0. + +See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt +//// + +[#design] +# Design +:idprefix: design_ + +## Features + +This `variant` implementation has two distinguishing features: + +* It's never "valueless", that is, `variant` has an + invariant that it always contains a valid value of one of the types + `T1`, `T2`, ..., `Tn`. +* It provides the strong exception safety guarantee on assignment and + `emplace`. + +This is achieved with the use of double storage, unless all of the +contained types have a non-throwing move constructor. + +## Rationale + +... + +## Differences with std::variant + +The main differences between this implementation and `std::variant` are: + +* No valueless-by-exception state: `valueless_by_exception()` always + returns `false`. +* Strong exception safety guarantee. +* `emplace` first constructs the new value and then destroys the old one; + in the single storage case, this translates to constructing a temporary + and then moving it into place. +* A converting constructor from, e.g. `variant` to + `variant` is provided as an extension +* The reverse operation, going from `variant` to + `variant` is provided as the member function `subset`. + (This operation can throw if the current state of the variant cannot be + represented.) +* `variant` is not (yet) trivial when all contained types are trivial, + as mandated by {cpp}17. +* The {cpp}20 additions and changes to `std::variant` have not yet been + implemented. + +## Differences with Boost.Variant + +... diff --git a/doc/variant2/implementation.adoc b/doc/variant2/implementation.adoc new file mode 100644 index 0000000..2673da1 --- /dev/null +++ b/doc/variant2/implementation.adoc @@ -0,0 +1,25 @@ +//// +Copyright 2019 Peter Dimov + +Distributed under the Boost Software License, Version 1.0. + +See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt +//// + +[#implementation] +# Implementation +:idprefix: implementation_ + +## Dependencies + +This implementation depends on Boost.Config and Boost.Mp11. + +## Supported Compilers + +* GCC 4.8 or later with `-std=c++11` or above +* Clang 3.5 or later with `-std=c++11` or above +* Visual Studio 2015, 2017 + +Tested on https://travis-ci.org/pdimov/variant2/[Travis] and +https://ci.appveyor.com/project/pdimov/variant2/[Appveyor].