Am 27.06.19 um 09:06 schrieb degski via Boost:
On Thu, 27 Jun 2019 at 09:54, Alexander Grund via Boost < boost@lists.boost.org> wrote:
Am 27.06.19 um 08:45 schrieb degski via Boost:
As from C++11 std::swap is marked noexcept, so yes. As from C++20 it's also constexpr, so now it can definitely cannot throw.
degski Are you sure? According to https://en.cppreference.com/w/cpp/algorithm/swap this is only non-throwing if it can be moved without throwing
Yes, but std::swap must also not invalidate any references, pointers, or iterators referring to the elements of the containers being swapped, which leaves the scope for throwing rather small [if at all possible].
degski
Combining it with "Some implementations of std::list throw from their move constructors" (David Sankel) leads to `std::swap(list1, list2)` can throw and hence is not `noexcept(true)` This applies to any "strange" class whose move may throw which was the motivation of that (part of the) discussion. So answering
Is there a good reason that variants should support such classes?
Maybe. At least it is also supported by std::move