Date: Fri, 7 Feb 2020 09:28:54 +0200
On Fri, 7 Feb 2020 at 09:05, Herb Sutter via Lib-Ext
<lib-ext_at_[hidden]> wrote:
> Aren't local references useful to express aliases, for example to a member of an array or container?
>
> Yes. Pointers can do it equivalently, it's a style choice.
>
> For example, this local reference is useful:
>
> int& r = a[f(i)];
>
> // ... then use r repeatedly ...
>
> Or you can equivalently use a pointer:
>
> int* p = a[f(i)];
>
> // ... then use *p repeatedly ...
Is that latter line intended to be
int* p = &a[f(i)];
?
<lib-ext_at_[hidden]> wrote:
> Aren't local references useful to express aliases, for example to a member of an array or container?
>
> Yes. Pointers can do it equivalently, it's a style choice.
>
> For example, this local reference is useful:
>
> int& r = a[f(i)];
>
> // ... then use r repeatedly ...
>
> Or you can equivalently use a pointer:
>
> int* p = a[f(i)];
>
> // ... then use *p repeatedly ...
Is that latter line intended to be
int* p = &a[f(i)];
?
Received on 2020-02-07 01:31:43