[libcxx-commits] [libcxx] Speed up compilation of common uses of std::visit() (PR #164196)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 29 06:28:10 PST 2025
================
@@ -1578,11 +1578,42 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __throw_if_valueless(_Vs&&... __vs) {
}
}
-template < class _Visitor, class... _Vs, typename>
+template <class _Visitor, class... _Vs, typename>
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
- using __variant_detail::__visitation::__variant;
- std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
- return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
+# define _XDispatchIndex(_I) \
----------------
higher-performance wrote:
Updated the code to do the same thing for `visit<R>`, and to go up to 11 instead of 8 to match libstdc++.
https://github.com/llvm/llvm-project/pull/164196
More information about the libcxx-commits
mailing list