Commit aafaa325 by Jonathan Wakely Committed by Jonathan Wakely

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
parent 46dbeb40
2018-03-26 Jonathan Wakely <jwakely@redhat.com>
* 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 <jwakely@redhat.com> 2018-03-22 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/85040 PR libstdc++/85040
......
...@@ -223,13 +223,17 @@ namespace __variant ...@@ -223,13 +223,17 @@ namespace __variant
template<size_t _Np, typename _Union> template<size_t _Np, typename _Union>
constexpr decltype(auto) __get(in_place_index_t<_Np>, _Union&& __u) 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. // Returns the typed storage for __v.
template<size_t _Np, typename _Variant> template<size_t _Np, typename _Variant>
constexpr decltype(auto) __get(_Variant&& __v) 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 // Various functions as "vtable" entries, where those vtables are used by
...@@ -358,10 +362,9 @@ namespace __variant ...@@ -358,10 +362,9 @@ namespace __variant
template <typename... _Types> template <typename... _Types>
using __select_index = using __select_index =
typename __select_int::_Select_int_base<sizeof...(_Types)+1, typename __select_int::_Select_int_base<sizeof...(_Types) + 1,
unsigned char, unsigned char,
unsigned short> unsigned short>::type::value_type;
::type::value_type;
template<typename... _Types> template<typename... _Types>
struct _Variant_storage<false, _Types...> struct _Variant_storage<false, _Types...>
...@@ -1304,6 +1307,12 @@ namespace __variant ...@@ -1304,6 +1307,12 @@ namespace __variant
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE #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<size_t _Np, typename _Vp> template<size_t _Np, typename _Vp>
friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v); friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment