🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #123

A bit of a pointless puzzle: avoiding copy constructor

#123
From: 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
Technical Details
Message-ID: <11adsj0$1ub96$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Andrey Tarasevich <noone@noone.net>
Newsgroups: comp.lang.c++
Subject: A bit of a pointless puzzle: avoiding copy constructor
Date: Sat, 10 Oct 2026 10:27:59 -0700
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <11adsj0$1ub96$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 10 Oct 2026 17:28:01 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2043174"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ePjFkKtcq7d4jh9CsA+/+"; posting-host="7f801c3fa9925236b461fc62787bea44"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8bbeqcYjZXd/if+t2dxNjt5P1UY= sha256:6Q38r7HHoYFro6HZURBJpie4ZqOQOWvc9Cos+VrOzmI=
	sha1:InkTnrEwHLf2m6GfQDoLxxTjRBA= sha256:OD8szZBUV4YzU2OHKRS9vvEcIBFPeU0Zsose+0JLOKE=
Content-Language: en-US