C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Template qualifiers
From: language.lawyer_at_[hidden]
Date: 2019-09-29 07:54:49


http://wg21.link/P0847

On 29/09/2019 15:52, Phil Bouchard via Std-Proposals wrote:
> Greetings,
>
>
> How many time did we have to redundantly write the same member functions just to add a const version? Ex.:
>
> struct A
>
> {
>
>     A & operator = (A const &) { return * this; }
>
>     A const & operator = (A const &) const { return * this; }
>
> };
>
>
> What I would like to suggest would be to templatize those instances as such:
>
> struct A
>
> {
>
>     template <qualifier Q>
>
>         A Q & operator = (A const &) Q { return * this; }
>
> };
>
>
> This would in instantiate on-the-fly the 2 (or 4) versions of the same code.
>
>
> Thank you,
>
>


STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups