C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Template qualifiers
From: Phil Bouchard (phil_at_[hidden])
Date: 2019-09-29 13:01:22


Sorry I haven't read about recursive lambdas yet but here is a better
example in order to have unique functionality, including move semantics:

struct A
{

 Â Â Â  int i;

 Â Â Â  A & operator = (A const & a) { i = a.i; return * this; }
 Â Â Â  A & operator = (A && a) { i = std::move(a.i); return * this; }
 Â Â Â  A volatile & operator = (A const & a) volatile { i = a.i; return *
this; }
 Â Â Â  A volatile & operator = (A && a) volatile { i = std::move(a.i);
return * this; }
};

struct A
{

 Â Â Â  int i;

 Â Â Â  template <qualifier Q, qualifier P>
 Â Â Â Â Â Â Â  A Q & operator = (A P a) Q { i = std::move_or_copy(a.i); return
* this; }
};

Where:

template <typename T>
 Â Â Â  typename std::remove_reference<T>::type & move_or_copy( T const & t
) noexcept;

template <typename T>
 Â Â Â  typename std::remove_reference<T>::type && move_or_copy( T && t )
noexcept;

It follows the purpose of the "template" notion as well.

-- 
*Phil Bouchard*
Founder
C.: (819) 328-4743
Fornux Logo <http://www.fornux.com>
On 9/29/19 12:50 PM, Gašper Ažman wrote:
> This proposal introduces a new kind of entity - a qualifier - which 
> will need to operate correctly with all parts of the language, and it 
> does not solve the problem of recursive lambdas, nor all save the 
> deduction of the qualifier that "deducing this" solves. I think there 
> is a pretty large body of work required here before it's a better 
> solution. All the other parameters can already be handled with 
> existing metaprogramming, too.
>
> Gašper
>
> On Sun, Sep 29, 2019, 14:14 Phil Bouchard via Std-Proposals 
> <std-proposals_at_[hidden] 
> <mailto:std-proposals_at_[hidden]>> wrote:
>
>     The approach I propose is more generic as it can apply to all
>     other parameters as well; not only "this".
>
>
>     -- 
>
>     *Phil Bouchard*
>     Founder
>     C.: (819) 328-4743
>
>     Fornux Logo <http://www.fornux.com>
>     -- 
>     Std-Proposals mailing list
>     Std-Proposals_at_[hidden] <mailto:Std-Proposals_at_[hidden]>
>     https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


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

Standard Proposals Archives on Google Groups