C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Allow '.' to behave like '->' where it is currently an error

From: Hubert Tong <hubert.reinterpretcast_at_[hidden]>
Date: Fri, 28 Feb 2020 23:42:40 -0500
On Fri, Feb 28, 2020 at 10:25 PM J Decker via Liaison <
liaison_at_[hidden]> wrote:

> On Fri, Feb 28, 2020 at 10:07 AM Patrice Roy via Liaison <
> liaison_at_[hidden]> wrote:
>> My initial point in response to your message was to point out that in
>> C++, there are cases where making '.' behave as '->' does today breaks
>> otherwise correct code and introduces ambiguity.
>> C++ users, contrary to C# or Java users, have the option of using objects
>> directly or indirectly. In C# (excluding structs) and Java, all objects are
>> accessed through indirect means. On the other hand, for a C++ programmer
>> using a smart pointer such as unique_ptr<T>, the ability to distinguish the
>> services exposed by that object (using '.') and those exposed by the
>> pointee (using '->') carries meaning, and that distinction is not readily
>> accessible in some other languages this proposal refers to.
>> Please also note that operator-> can be (and is sometimes) overloaded in
>> C++ classes.
> I'm failing to communicate 'where it is now an error'.
I think the clarification needs to go beyond that. Using . on a class
instance where the name to the right does not clearly name a specific
member is also an error.

Received on 2020-02-28 22:45:40