C++ Logo

std-proposals

Advanced search

Template qualifiers

From: Phil Bouchard <phil_at_[hidden]>
Date: Sun, 29 Sep 2019 08:52:06 -0400
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,

-- 
*Phil Bouchard*
Founder
C.: (819) 328-4743
Fornux Logo <http://www.fornux.com>

Received on 2019-09-29 07:54:19