C++ Logo

std-proposals

Advanced search

Re: Allow '.' to behave like '->' where it is currently an error.

From: Olaf van der Spek <ml_at_[hidden]>
Date: Sat, 29 Feb 2020 08:20:31 +0100
On Thu, Feb 27, 2020 at 3:32 PM J Decker <d3ck0r_at_[hidden]> wrote:
>
>
>
> On Thu, Feb 27, 2020 at 4:00 AM Olaf van der Spek via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> On Fri, Feb 21, 2020 at 9:12 AM Михаил Найденов via Std-Proposals
>> <std-proposals_at_[hidden]> wrote:
>> > For C++ the value is indeed possibly negative, as this will literally promote using raw pointers because their special properties.
>> >
>> > we try to promote
>> >
>> > something(const object& o);
>> > instead of
>> > something(const object* o);
>>
>> Wouldn't a better solution be for C to adopt references?
>
>
> Not really, because to pass the first one you'd have to have an instance defined on the stack, and couldn't use a pool of objects; perhaps that object has a complex construction....
> You can't save a reference for later.. struct { int &a; }s;
>
> references project data from 'here' to 'there', I really just want to work with data where it is; (probably 'there' because the caller didn't directly create it).

object* p = ...;
something_ptr(p);
something_ref(*p);

No stack instance required and you can save references for later. p
shouldn't be NULL though.


-- 
Olaf

Received on 2020-02-29 01:23:25