diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc index a837766..785eac9 100644 --- a/doc/variant2/changelog.adoc +++ b/doc/variant2/changelog.adoc @@ -1,16 +1,18 @@ //// Copyright 2019-2021 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 +https://www.boost.org/LICENSE_1_0.txt //// [#changelog] # Revision History :idprefix: changelog_ +## Changes in 1.78.0 + +* Added ``. +* Added `unsafe_get`. + ## Changes in 1.76.0 * Improved generated code for the double buffered case. diff --git a/doc/variant2/reference.adoc b/doc/variant2/reference.adoc index b5d5a84..ced354a 100644 --- a/doc/variant2/reference.adoc +++ b/doc/variant2/reference.adoc @@ -1,10 +1,7 @@ //// -Copyright 2018, 2019 Peter Dimov - +Copyright 2018-2021 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 +https://www.boost.org/LICENSE_1_0.txt //// [#reference] @@ -117,6 +114,21 @@ template constexpr add_pointer_t get_if(const variant* v) noexcept; +// unsafe_get (extension) + +template + constexpr variant_alternative_t>& + unsafe_get(variant& v); +template + constexpr variant_alternative_t>&& + unsafe_get(variant&& v); +template + constexpr const variant_alternative_t>& + unsafe_get(const variant& v); +template + constexpr const variant_alternative_t>&& + unsafe_get(const variant&& v); + // relational operators template @@ -775,6 +787,34 @@ Requires: :: The type `U` occurs exactly once in `T...`. Otherwise, the Effects: :: Equivalent to: `return get_if(v);` with `I` being the zero-based index of `U` in `T...`. +### unsafe_get (extension) + +``` +template + constexpr variant_alternative_t>& + unsafe_get(variant& v); +``` +``` +template + constexpr variant_alternative_t>&& + unsafe_get(variant&& v); +``` +``` +template + constexpr const variant_alternative_t>& + unsafe_get(const variant& v); +``` +``` +template + constexpr const variant_alternative_t>&& + unsafe_get(const variant&& v); +``` +[none] +* {blank} ++ +Requires: :: `v.index() == I`. +Returns: :: a reference to the object stored in the variant. + ### Relational Operators ``` @@ -878,3 +918,7 @@ public: } }; ``` + +## + +This convenience header includes ``.