[PATCH] Constrain swap overload for std::optional (LWG 2748)

Jonathan Wakely jwakely@redhat.com
Tue Nov 15 14:33:00 GMT 2016


This implements the resolution to LWG 2748 which was approved the
other day at the WG21 meeting. I think the resolution is wrong,
because as the test shows it means that optional<NonSwappable> is
swappable in some cases. I've raised that with the LWG and will
probably create a new issue for it, but in the meantime this
implements what the spec says.

	* doc/xml/manual/intro.xml: Document LWG 2748 status.
	* include/std/optional (optional<T>::swap): Use is_nothrow_swappable_v
	for exception specification.
	(swap(optional<T>&, optional<T>&)): Disable when T is not swappable.
	* testsuite/20_util/optional/swap/2.cc: New test.

Tested powerpc64le-linux.

This only affects experimental C++17 stuff, so I'm committing it even
though we're in Stage 3.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4541 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20161115/db3eac53/attachment.bin>


More information about the Libstdc++ mailing list