Date: Mon, 3 May 2021 01:43:25 +0300
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
}
https://wandbox.org/permlink/IorTlLx0hrRNiTU0
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_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
}
https://wandbox.org/permlink/IorTlLx0hrRNiTU0
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.
Received on 2021-05-02 17:43:38