Commit 7d5abe42 by Tim Shen Committed by Tim Shen

re PR libstdc++/79513 (std::visit doesn't handle references)

	PR libstdc++/79513
	* include/std/variant (visit()): Forward variant types to the return
	type detection code.
	* testsuite/20_util/variant/compile.cc: Add test cases.

From-SVN: r245474
parent fdbb4622
2017-02-15 Tim Shen <timshen@google.com>
PR libstdc++/79513
* include/std/variant (visit()): Forward variant types to the return
type detection code.
* testsuite/20_util/variant/compile.cc: Add test cases.
2017-02-13 H.J. Lu <hongjiu.lu@intel.com>
PR libstdc++/79348
......
......@@ -1263,7 +1263,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__throw_bad_variant_access("Unexpected index");
using _Result_type =
decltype(std::forward<_Visitor>(__visitor)(get<0>(__variants)...));
decltype(std::forward<_Visitor>(__visitor)(
get<0>(std::forward<_Variants>(__variants))...));
constexpr auto& __vtable = __detail::__variant::__gen_vtable<
_Result_type, _Visitor&&, _Variants&&...>::_S_vtable;
......
......@@ -291,6 +291,12 @@ void test_visit()
};
static_assert(visit(Visitor(), variant<int, nonliteral>(0)), "");
}
// PR libstdc++/79513
{
std::variant<int> v [[gnu::unused]] (5);
std::visit([](int&){}, v);
std::visit([](int&&){}, std::move(v));
}
}
void test_constexpr()
......
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