C++ Logo


Advanced search

Subject: Re: [std-proposals] is_value_constructible
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2021-05-02 17:43:25

On Mon, 3 May 2021 at 00:34, Jason McKesson via Std-Proposals
<std-proposals_at_[hidden]> wrote:

> > This problem often comes up when writing variadic forwarding constructors, for which writing the test is a bit of a pain.
> I guess my confusion is why you want to *prevent* a "variadic
> forwarding constructor" from performing a copy/move. If you're worried
> about the forwarding constructor interfering with the actual copy/move
> constructor for the main type, it won't: templates are *never*
> considered copy/move constructors.

But it does interfere.

#include <iostream>

struct X
    X() = default;
    X(const X&) { std::cout << "copy\n";}
    template <class... T>
    X(T&&...) {std::cout << "variadic\n";}

int main()
    X x;
    X x2(x); // this will call the variadic template


That's an undesirable result for various kinds of wrapper types,
because in that situation they will attempt
to wrap, instead of copying the wrapped guts.

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups