C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Copy-construct, move-construct, and PR-construct

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Wed, 23 Aug 2023 21:42:15 +0100
On Wed, Aug 23, 2023 at 4:34 PM Arthur O'Dwyer via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> That's the "super-constructing super-elider"
> https://quuxplusone.github.io/blog/2018/05/17/super-elider-round-2/
> and it already works great and needs no help from the paper standard...


Arthur I took a look on your website at the following example which
falls down because the constructor is a template function:

    struct Widget {
       template<class U>
        explicit Widget(U&&)
        {
            printf(" %s -- OOPS!\n", __PRETTY_FUNCTION__);
        }
    };

This problem could be remedied if we were able to tell the compiler
that a given class should never become a template parameter type. For
example:

    class !template MyClass {
        int a;
    };

    std::vector<MyClass> myvec; /* fails to compile - can't bind
MyClass to parameter type T */

If you don't like the "!template" then here's a few other ways we
could write it:

    class noparam MyClass { int a; };
    class MyClass !template { int a; };
    class MyClass noparam { int a; };
    !template class MyClass { int a; };
    nobindparam class MyClass { int a; };
    class MyClass { int a; } !template;
    class MyClass { int a; } nobind;

Received on 2023-08-23 20:42:28