From aafaa3254ec6fc3d5e3a15a40185950d3af04432 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 26 Mar 2018 14:09:10 +0100 Subject: [PATCH] Add workaround to std::variant for Clang bug 31852 * include/std/variant (__get): Qualify calls to avoid ADL. (__select_index): Adjust whitespace. (variant): Add using-declaration to workaround Clang bug. From-SVN: r258854 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/std/variant | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5d2620d..bdd4c6b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2018-03-26 Jonathan Wakely + + * include/std/variant (__get): Qualify calls to avoid ADL. + (__select_index): Adjust whitespace. + (variant): Add using-declaration to workaround Clang bug. + 2018-03-22 Jonathan Wakely PR libstdc++/85040 diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 4aba131..e4ae657 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -223,13 +223,17 @@ namespace __variant template constexpr decltype(auto) __get(in_place_index_t<_Np>, _Union&& __u) - { return __get(in_place_index<_Np-1>, std::forward<_Union>(__u)._M_rest); } + { + return __variant::__get(in_place_index<_Np-1>, + std::forward<_Union>(__u)._M_rest); + } // Returns the typed storage for __v. template constexpr decltype(auto) __get(_Variant&& __v) { - return __get(std::in_place_index<_Np>, std::forward<_Variant>(__v)._M_u); + return __variant::__get(std::in_place_index<_Np>, + std::forward<_Variant>(__v)._M_u); } // Various functions as "vtable" entries, where those vtables are used by @@ -358,10 +362,9 @@ namespace __variant template using __select_index = - typename __select_int::_Select_int_base - ::type::value_type; + unsigned short>::type::value_type; template struct _Variant_storage @@ -1304,6 +1307,12 @@ namespace __variant #undef _VARIANT_RELATION_FUNCTION_TEMPLATE +#ifdef __clang__ + public: + using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852 + private: +#endif + template friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v); -- 2.7.4