diff --git a/doc/variant2/changelog.adoc b/doc/variant2/changelog.adoc index e16daa2..66905bf 100644 --- a/doc/variant2/changelog.adoc +++ b/doc/variant2/changelog.adoc @@ -8,6 +8,10 @@ https://www.boost.org/LICENSE_1_0.txt # Revision History :idprefix: changelog_ +## Changes in 1.91.0 + +* `holds_alternative` and `get` have been relaxed to no longer require `T` to occur exactly once in the list of alternatives. It now must occur at least once. + ## Changes in 1.90.0 * More functions have been marked as `constexpr`, including `~variant`. diff --git a/doc/variant2/reference.adoc b/doc/variant2/reference.adoc index fe38344..59b9cb2 100644 --- a/doc/variant2/reference.adoc +++ b/doc/variant2/reference.adoc @@ -719,10 +719,8 @@ template [none] * {blank} + -Requires: :: The type `U` occurs exactly once in `T...`. Otherwise, the - program is ill-formed. -Returns: :: `true` if `index()` is equal to the zero-based index of `U` - in `T...`. +Requires: :: The type `U` must be present in `T...`. Otherwise, the program is ill-formed. +Returns: :: `true` if `v` holds a value of type `U`, otherwise `false`. ### get @@ -773,10 +771,8 @@ template [none] * {blank} + -Requires: :: The type `U` occurs exactly once in `T...`. Otherwise, the - program is ill-formed. -Effects: :: If `v` holds a value of type `U`, returns a reference to that value. - Otherwise, throws `bad_variant_access`. +Requires: :: The type `U` must be present in `T...`. Otherwise, the program is ill-formed. +Effects: :: If `v` holds a value of type `U`, returns a reference to that value. Otherwise, throws `bad_variant_access`. ### get_if @@ -793,10 +789,8 @@ template [none] * {blank} + -Effects: :: A pointer to the value stored in the variant, if - `v != nullptr && v\->index() == I`. Otherwise, `nullptr`. -Remarks: :: These functions do not participate in overload resolution - unless `I` < `sizeof...(T)`. +Returns: :: A pointer to the value stored in `*v`, if `v != nullptr && v\->index() == I`. Otherwise, `nullptr`. +Remarks: :: These functions do not participate in overload resolution unless `I` < `sizeof...(T)`. ``` template @@ -811,10 +805,8 @@ template [none] * {blank} + -Requires: :: The type `U` occurs exactly once in `T...`. Otherwise, the - program is ill-formed. -Effects: :: Equivalent to: `return get_if(v);` with `I` being - the zero-based index of `U` in `T...`. +Requires: :: The type `U` must be present in `T...`. Otherwise, the program is ill-formed. +Returns: :: If `v != nullptr` and `*v` holds a value of type `U`, a pointer to that value. Otherwise, `nullptr`. ### unsafe_get (extension)