[RFC] Deprecate non-standard constructors in std::pair

Ville Voutilainen ville.voutilainen@gmail.com
Wed Apr 7 18:25:57 GMT 2021


On Wed, 7 Apr 2021 at 21:17, Jonathan Wakely <jwakely@redhat.com> wrote:
> This fails to compile because of that bug:
>
> #include <utility>
>
> struct X {
>    X(void* = 0) { }
>    X(const X&) = default;
>    X(const X&&) = delete;
> };
>
> struct move_only {
>    move_only() = default;
>    move_only(move_only&&) = default;
> };
>
> std::pair<move_only, X> p0(move_only(), 0);
> std::pair<move_only, X> p1(move_only(), {});
>
> The pair(U1&&, const T2&) constructor should be viable, but it fails
> the _MoveCopyPair constraint check because X(const X&&) is deleted.
>
> I'm not sure I care about this though. It would only work because of
> those non-standard constructors which we're talking about deprecating.
> I'm not very motivated to fix them so they accept this, when we're
> going to deprecate them anyway.

Nah, let's not bother. The type X has an explicitly deleted move
constructor, which the library
doesn't go to heroic extents to support.


More information about the Libstdc++ mailing list