]> git.ipfire.org Git - thirdparty/gcc.git/commit
Avoid redundant runtime checks in std::visit
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Oct 2018 14:00:50 +0000 (14:00 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Oct 2018 14:00:50 +0000 (14:00 +0000)
commit4429133c7570bfef5ce5deb2fb3e124ec59dee9c
treea69a6ba487c13ad4ce8f595f485a8f2f0daefdf1
parent28c3ce2dc72b90a9bd1f5f99d75f7b496708c1a6
Avoid redundant runtime checks in std::visit

Calling std::get will check some static assertions and also do a runtime
check for a valid index before calling __detail::__variant::__get. The
std::visit function already handles the case where any variant has an
invalid index, so __get can be used directly in __visit_invoke.

* include/std/variant (__gen_vtable_impl::__visit_invoke): Call __get
directly instead of get, as caller ensures correct index is used.
(holds_alternative, get, get_if): Remove redundant inline specifiers.
(_VARIANT_RELATION_FUNCTION_TEMPLATE): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264786 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/variant