• A bit of a pointless puzzle: avoiding copy constructor

    From Andrey Tarasevich@3:633/10 to All on Sat Oct 10 10:27:59 2026
    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

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Sat Oct 10 17:38:53 2026
    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.)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)