libstdc++: Simplify std::optional::value()
authorJonathan Wakely <jwakely@redhat.com>
Tue, 27 Jul 2021 13:50:28 +0000 (14:50 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 27 Jul 2021 20:36:01 +0000 (21:36 +0100)
commit9360d6cd1706882dfffd3c7a08b5956c37207a11
treee03975117aa828b80f557d0d4f7695f8696c00f8
parentb7195fb01fe62a313ae5f7faede698101bdb3025
libstdc++: Simplify std::optional::value()

The structure of these functions likely dates from the time before G++
fully supported C++14 extended constexpr, so that the throw expression
had to be the operand of a conditional expression. That is not true now,
so we can use a more straightforward version of the code.

We can also simplify the declaration of __throw_bad_optional_access by
using the C++11-style [[noreturn]] attribute so that a separate
declaration isn't needed.

libstdc++-v3/ChangeLog:

* include/experimental/optional (__throw_bad_optional_access):
Replace GNU attribute with C++11 attribute.
(optional::value, optional::value_or): Use if statements
instead of conditional expressions.
* include/std/optional (__throw_bad_optional_access)
(optional::value, optional::value_or): Likewise.
libstdc++-v3/include/experimental/optional
libstdc++-v3/include/std/optional