From d16968176795a116c547d27c27d3761369bbda27 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jun 2017 22:01:43 +0300 Subject: [PATCH] Update README.md --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 66c3ac4..6684a35 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # variant2 -This repository contains a never-valueless C++14 implementation of [std::variant](http://en.cppreference.com/w/cpp/utility/variant) in [variant.hpp](include/boost/variant2/variant.hpp) and an implementation of `expected` in [expected.hpp](include/boost/variant2/expected.hpp) that is an extended version of `extended` as proposed in [P0323R1](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0323r1.pdf) and the subsequent [D0323R2](https://github.com/viboes/std-make/blob/master/doc/proposal/expected/d0323r2.md). +This repository contains a never-valueless C++14 implementation of [std::variant](http://en.cppreference.com/w/cpp/utility/variant) in [variant.hpp](include/boost/variant2/variant.hpp) and an implementation of `expected` in [expected.hpp](include/boost/variant2/expected.hpp) that is an extended version of `expected` as proposed in [P0323R1](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0323r1.pdf) and the subsequent [D0323R2](https://github.com/viboes/std-make/blob/master/doc/proposal/expected/d0323r2.md). The code requires [mp11](https://github.com/pdimov/mp11) and Boost.Config. The repository is intended to be placed into the `libs/variant2` directory of a Boost clone or release, with mp11 in `libs/mp11`, but the headers will also work standalone if [mp11.hpp](https://github.com/pdimov/mp11/blob/master/include/boost/mp11.hpp) or [mp11_single.hpp](https://github.com/pdimov/mp11/blob/master/include/boost/mp11_single.hpp) is included beforehand. @@ -10,20 +10,21 @@ Supported compilers: * clang++ 3.5 or later with -std=c++14 or -std=c++1z * Visual Studio 2017 +Tested on [Travis](https://travis-ci.org/pdimov/variant2/) and [Appveyor](https://ci.appveyor.com/project/pdimov/variant2/). + ## variant.hpp The class `boost::variant2::variant` is an almost conforming implementation of `std::variant` with the following differences: -* The function `valueless_by_exception()` is not present, as the variant is never valueless; * 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.) -To avoid the valueless state, this implementation falls back to using double storage unless +To avoid going into a valueless-by-exception state, this implementation falls back to using double storage unless * all the contained types are nothrow move constructible, or -* at least one contained type has a nothrow default constructor. +* the list of alternatives contains the type `valueless`. -If the second bullet doesn't hold, but the first does, the variant uses single storage, but `emplace` constructs a temporary and moves it into place if the construction of the object can throw. In case this is undesirable, the recommended practice is to add an alternative that has a nonthrowing default constructor. +If the second bullet doesn't hold, but the first does, the variant uses single storage, but `emplace` constructs a temporary and moves it into place if the construction of the object can throw. In case this is undesirable, one can force `emplace` into always constructing in-place by adding `valueless` to the list of alternatives. ## expected.hpp