Re: Coding style for C++ constructs going forward
Liu Hao via Gcc <[email protected]>
| Newsgroups | gmane.comp.gcc.devel,gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
在 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. -- Best regards, LH_Mouse
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEn9eDGptREvfrWRePQbMyeCIxW8QFAl8zWAwACgkQQbMyeCIx W8SK3hAAnbU8DEtH2GaGgOfHbrfeatVd0lNP8Aeqbtf7JpmOly7iu5IHnwh2N1gc BOfFJjEXHuv4MeRgLdtsJ/30Jg0zIMQMXvoar4EhIPXC+n9fxMwKMLEUf6q+lbUV ZHSQ9zPpV3JJsHsbhAjEueidf8PjP4zQNza15WifzZ8bCdl2DhBTVC0sIdKkSeAt VYBAvaQfRlKMtCVyx96Jj3ruzTDAE0D5p3lEz/TEf9EOrQuS+YKSlmaJpqWnbfiZ Y1KGkIw9UKTBK3iGDnLyAuepFu63KvMB8bGZ3lByBPQqZQPh50dlpKSl4ZF+0wU7 QvjpY38aGAfYgN0x7aY6QpNWDtOV3CiupyUS+FU3ogKcUOvTcjAowvAtUnAXYrOb mmJyeOgIe88UlzhF4RFEIMS4uQePnZIg0BcTsv6AwXbc0V0iUYYuXAx7A3g18h2u /2YT6MXRLsLZRW+bhQsYgOTmQQg0V+6Uqt3dW1b2Ff/NtGOjeLvnUI1D85nWyX3Y wwZqTAIDX6TK312Fk1uNPjro+E4biJqSACjDuXVpjl882rAPwLHDPR/c3AksnqPt /Y0fVOEf4E2jxsw/Zm3baYkMEbySPe1cZP3UncjvgLEfF0Hp53NZ8HJ5I1A2GKDq WkBbvnUrwF2gOp9M/qdTWx7gioENIs1KPqMh53IwR3myo4/ZEKY= =ofsj -----END PGP SIGNATURE-----