C++ Logo

std-proposals

Advanced search

Re: Improved Member Operator Syntax

From: Tae Lim Kook <uruwi_at_[hidden]>
Date: Thu, 17 Oct 2019 15:29:14 +0000
On Thursday, October 17, 2019 4:57 AM, Jake Arkinstall via Std-Proposals <std-proposals_at_[hidden]> wrote:

> It's an interesting idea. Perhaps it needn't be a change, but an addition - allow one or the other. I'm not sure if it's solving a major problem, but the whole fake int parameter bodge is certainly a slight annoyance.
>
> Im against using "this" though. "this" is a pointer and I believe it might confuse people to have a syntax that *almost* looks like a pointer increment but actually defines a custom increment on the object. If we had a keyword that mapped to (*this), E.g. Python's "self", I'd choose that keyword instead.

I have another idea for how to improve member operator syntax. How would this work?

ResultType operator infix+(RightSideType); // a + b
ResultType operator prefix+(); // +a
ResultType operator prefix++(); // ++a
ResultType operator postfix++(); // a++

Received on 2019-10-17 10:31:37