On Tue, Aug 11, 2020 at 7:49 PM Liu Hao via Gdb <g...@sourceware.org> wrote:
>
> 在 2020/8/11 下午9:55, Nathan Sidwell 写道:
> >
> > I agree, it's the way I use auto.  I particularly like the
> >    auto *foo = expr;
> > idiom, when you're getting a pointer, but the type of the pointee is clear. 
> >  It informs how you use 'foo'.
> >
> >
>
> Personally I dislike this syntax. Pointers are objects, and `auto foo = 
> expr;` should suffice. What if the type of `expr` is
> `unique_ptr<T>` or `optional<T>`? The ptr-operator just can't exist there. So 
> why the differentiation?
>
> `auto& foo = ...` and `const auto& foo = ...` are necessary to indicate that 
> the entity being declared is a reference (and
> is not an object), while `auto*` doesn't make much sense, as I discourage 
> plain pointers in my projects.

Then use of `auto*` would make it easier for you to spot use of plain
pointers in your projects & scrutinize them further?

>
>
>
> --
> Best regards,
> LH_Mouse
>

Reply via email to