🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Andrey Tarasevich Sat, 10 Oct 2026 17:27
A bit of a pointless puzzle: avoiding copy constructor
#123
Author: Andrey Tarasevich
Date: Sat, 10 Oct 2026 17:27
24 lines
1655 bytes
One can easily produce a definition for class `C`, under which the 
following copy-initialization

   C a, b = a;

will use some "other" constructor instead of the copy constructor.

But what about direct-initialization

   C a, b(a);

? Is there any way to somehow drive this form of initialization away 
from the copy-constructor and make it use some other constructor?

The

   const C a;
   C b(a);

case is easy, but what about plain `a`?

-- 
Best regards,
Andrey
Re: A bit of a pointless puzzle: avoiding copy constructor
#153
Author: Ross Finlayson
Date: Sun, 11 Oct 2026 00:38
26 lines
1980 bytes
On 10/10/2026 10:27 AM, Andrey Tarasevich wrote:
> One can easily produce a definition for class `C`, under which the
> following copy-initialization
>
>    C a, b = a;
>
> will use some "other" constructor instead of the copy constructor.
>
> But what about direct-initialization
>
>    C a, b(a);
>
> ? Is there any way to somehow drive this form of initialization away
> from the copy-constructor and make it use some other constructor?
>
> The
>
>    const C a;
>    C b(a);
>
> case is easy, but what about plain `a`?
>

(No.)

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads