Commit 9d89b73c by Jonathan Wakely Committed by Jonathan Wakely

Add comments and style fixes to <variant>

	* include/std/variant: Adjust whitespace. Add comments.
	(_Multi_array): Leave primary template undefined.
	(_Multi_array<_Tp>): Define partial specialization for base case of
	recursion.
	(__gen_vtable_impl, __gen_vtable): Remove redundant && from type
	which is always a reference.
	(__gen_vtable::_S_apply()): Remove function, inline body into
	default member initializer.
	* testsuite/20_util/variant/visit.cc: Test with noncopyable types.

From-SVN: r270238
parent 8701cb5e
2019-04-09 Jonathan Wakely <jwakely@redhat.com>
* include/std/variant: Adjust whitespace. Add comments.
(_Multi_array): Leave primary template undefined.
(_Multi_array<_Tp>): Define partial specialization for base case of
recursion.
(__gen_vtable_impl, __gen_vtable): Remove redundant && from type
which is always a reference.
(__gen_vtable::_S_apply()): Remove function, inline body into
default member initializer.
* testsuite/20_util/variant/visit.cc: Test with noncopyable types.
* include/std/variant (__variant_idx_cookie): Add member type.
(__visitor_result_type): Remove.
(__do_visit): Use invoke_result instead of __visitor_result_type.
......
......@@ -66,8 +66,30 @@ test01()
VERIFY( res == 35 );
}
void
test02()
{
struct NoCopy
{
NoCopy() { }
NoCopy(const NoCopy&) = delete;
NoCopy(NoCopy&&) = delete;
~NoCopy() { }
int operator()(int i) { return i; }
int operator()(const NoCopy&) { return 0; }
};
std::variant<NoCopy, int> v{1};
NoCopy f;
// Visit should not need arguments to be copyable:
int res = std::visit(f, v);
VERIFY( res == 1 );
}
int
main()
{
test01();
test02();
}
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