C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Let constructor know if object is const or volatile

From: connor horman <chorman64_at_[hidden]>
Date: Sat, 30 Sep 2023 10:19:35 -0400
TBH, I'd expect the this pointer being const in the constructor body, and
only allow initialization in the member initializer list.

I was also personally building a syntax with trailing cv-qualifiers like
for member functions.

On Sat, Sep 30, 2023 at 09:27 Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hi Edward, hi Frederick,
>
>
>
> about the first syntax:
>
> Using a const explicit object parameter for the constructor would be
> strange, if the this pointer is actually non-const during construction,
> even if the object is const.
>
>
>
> Best,
>
> Sebastian
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Frederick Virchanza Gotham via Std-Proposals <
> std-proposals_at_[hidden]>
> *Gesendet:* Sa 30.09.2023 13:08
> *Betreff:* Re: [std-proposals] Let constructor know if object is const or
> volatile
> *An:* Edward Catmur <ecatmur_at_[hidden]>;
> *CC:* Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>;
> std-proposals_at_[hidden];
>
> On Fri, Sep 29, 2023 at 7:15 PM Edward Catmur <ecatmur_at_[hidden]>
> wrote:
> >
> > Why not propose overloading the constructor on an explicit object
> parameter?
> >
> > Monkey::Monkey(this Monkey& self);
> > Monkey::Monkey(this Monkey const& self);
> >
> > But you still haven't provided motivation.
>
>
> I don't know how that didn't cross my mind. Another simple possibility:
>
> Monkey::Monkey(void) { /* stuff in here */ }
> Monkey::Monkey(void) const { /* stuff in here */ }
> Monkey::Monkey(void) volatile { /* stuff in here */ }
> Monkey::Monkey(void) const volatile { /* stuff in here */ }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2023-09-30 14:19:49