Coding style for C++ constructs going forward
David Blaikie
dblaikie@gmail.com
Wed Aug 12 18:40:05 GMT 2020
On Tue, Aug 11, 2020 at 7:49 PM Liu Hao via Gdb <gdb@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
>
More information about the Gdb
mailing list