C++ Logo


Advanced search

Subject: Re: [std-proposals] Template qualifiers
From: Tony V E (tvaneerd_at_[hidden])
Date: 2019-09-29 13:48:24

Is there some reason to use assignment as your example? It seems a strange example, since we don't normally assign to const objects, nor build assignments that don't assign. 

Maybe a more motivating and less distracting example would be better.

Sent from my BlackBerry portable Babbage Device
From: Phil Bouchard via Std-Proposals
Sent: Sunday, September 29, 2019 8:52 AM
To: std-proposals@lists.isocpp.org
Reply To: std-proposals@lists.isocpp.org
Cc: Phil Bouchard
Subject: [std-proposals] Template qualifiers


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,


Phil Bouchard
C.: (819) 328-4743

Fornux Logo

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

Standard Proposals Archives on Google Groups