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
+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"
constexpr bool
_M_valid() const noexcept
{
+ if constexpr ((is_scalar_v<_Types> && ...))
+ return true;
return this->_M_index != __index_type(variant_npos);
}