PR libstdc++/87431 optimise valueless_by_exception()
If a std::variant can never get into valueless state then we don't need to do a runtime check for a valid alternative. PR libstdc++/87431 * include/std/variant (_Variant_storage<true, _Types...>::_M_valid): Avoid runtime test when all alternatives are scalars and so cannot throw during initialization. From-SVN: r264574
This commit is contained in:
parent
4fb792e189
commit
16d30bbd4d
|
@ -1,3 +1,10 @@
|
|||
2018-09-25 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/87431
|
||||
* include/std/variant (_Variant_storage<true, _Types...>::_M_valid):
|
||||
Avoid runtime test when all alternatives are scalars and so cannot
|
||||
throw during initialization.
|
||||
|
||||
2018-09-25 Gerald Pfeifer <gerald@pfeifer.com>
|
||||
|
||||
* doc/xml/manual/codecvt.xml: Move link to "UTF-8 and Unicode FAQ"
|
||||
|
|
|
@ -439,6 +439,8 @@ namespace __variant
|
|||
constexpr bool
|
||||
_M_valid() const noexcept
|
||||
{
|
||||
if constexpr ((is_scalar_v<_Types> && ...))
|
||||
return true;
|
||||
return this->_M_index != __index_type(variant_npos);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue