C++ Logo

std-discussion

Advanced search

Re: Potential defect in the behaviour of the rvalue constructors for std::tuple and std::pair.

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 11 Nov 2023 01:20:04 +0200
On Sat, 11 Nov 2023 at 01:01, Bryan Wong via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> Hi all,
>
> I think I've identified a potential defect in the rvalue constructors for `std::tuple` covered under `22.4.4.1 tuple.cnstr p.20-23` on the latest draft and wanted to ask about it before making a formal report (may also need guidance here if possible, as I've never done it before). I'm also not sure if this issue has been raised before.
>
> When using the tuple rvalue constructors, unexpected behaviour occurs with non-movable but copyable types, e.g.
>
> struct foo {
> foo() = default;
> foo(foo const&) = default;
> foo& operator=(foo const&) = default;
> foo(foo&&) = delete;
> foo& operator=(foo&&) = delete;
> };

That type is an abomination. If you can copy a type, you can also move
it, and that just then does the same thing as copy if it can't move.
The standard library doesn't support types that are copyable but for
which move operations are ill-formed. Such types make
no sense, and appear only ever in testsuites.

Received on 2023-11-10 23:20:17