Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #72243 > unrolled thread
| Started by | jacobnavia <jacob@jacob.remcomp.fr> |
|---|---|
| First post | 2020-03-13 00:13 +0100 |
| Last post | 2020-03-21 01:43 -0700 |
| Articles | 20 on this page of 122 — 17 participants |
Back to article view | Back to comp.lang.c++
Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-13 00:13 +0100
Re: Structured binding considered harmful Maciej Sobczak <see.my.homepage@gmail.com> - 2020-03-13 00:46 -0700
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 09:10 +0100
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-13 09:40 -0700
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 09:05 +0100
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-14 03:19 -0700
Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-15 11:08 +0000
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-15 09:46 -0700
Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-15 19:27 +0100
Re: Structured binding considered harmful Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-03-15 15:15 -0700
Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-16 05:23 +0100
Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-16 05:54 +0100
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-16 00:20 -0700
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-13 23:08 -0400
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 08:59 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-14 10:09 -0400
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 18:32 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-14 18:33 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-15 17:50 +0100
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-16 00:11 +0100
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-16 05:24 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 06:46 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-16 12:52 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 08:32 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-16 13:51 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 20:06 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-17 06:37 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-17 07:17 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-17 18:37 +0100
Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-17 18:50 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 06:30 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 11:38 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 08:17 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 13:19 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 08:31 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 14:15 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 10:13 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 15:45 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 11:36 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 17:59 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 13:18 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 18:27 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 14:41 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 19:46 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 19:46 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-19 06:41 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-19 07:02 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-19 12:41 +0100
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-19 06:10 -0700
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-19 14:15 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-19 19:23 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-20 09:18 +0100
Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-20 05:31 -0700
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-20 13:40 +0100
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-20 08:50 -0700
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 09:30 -0700
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-20 10:13 -0700
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 10:36 -0700
Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-21 12:06 +1300
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-20 16:37 -0700
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 17:17 -0700
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-21 10:09 -0700
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 11:21 -0700
Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-21 13:09 -0700
Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-21 22:33 +0000
Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-20 17:30 +0000
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 10:49 -0700
Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-20 18:47 +0000
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-20 17:41 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-20 18:06 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 06:31 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 09:50 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 14:59 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 10:42 -0400
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 16:09 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 11:12 -0400
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-20 18:05 -0400
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 15:57 -0700
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-20 23:23 -0400
Re: Structured binding considered harmful Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-03-20 21:08 -0700
Re: Structured binding considered harmful Ralf Goertz <me@myprovider.invalid> - 2020-03-21 08:24 +0100
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 01:36 -0700
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 06:30 +0100
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 09:51 -0400
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-22 13:22 +0100
Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-22 13:24 +0000
Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-22 06:32 -0700
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-22 07:59 -0700
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 13:02 -0400
Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-22 17:09 +0000
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 13:35 -0400
Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-22 17:54 +0000
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 17:19 -0400
Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-22 21:46 +0000
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 19:06 -0400
Re: Structured binding considered harmful danielaparker@gmail.com - 2020-03-22 17:11 -0700
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 22:16 -0400
Re: Structured binding considered harmful Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2020-03-25 20:38 +0000
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-25 20:01 -0400
Re: Structured binding considered harmful danielaparker@gmail.com - 2020-03-22 10:58 -0700
Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-23 07:41 +1300
Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-22 15:01 -0400
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 10:24 -0400
Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-20 20:15 -0700
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-21 08:32 +0100
Re: Structured binding considered harmful David Brown <david.brown@hesbynett.no> - 2020-03-21 11:27 +0100
Re: Structured binding considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2020-03-21 13:34 +0000
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 07:11 -0700
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 10:45 -0400
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 08:03 -0700
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-19 08:24 -0700
Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-19 09:05 +1300
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 19:47 -0400
Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-18 11:43 -0700
Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 19:48 +0100
Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-18 12:37 -0700
Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-16 16:11 +0100
Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-17 08:17 +1300
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-16 13:12 -0700
Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 20:13 -0400
Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-17 19:46 +0000
Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 01:43 -0700
Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7 Next page →
| From | Sam <sam@email-scan.com> |
|---|---|
| Date | 2020-03-18 13:18 -0400 |
| Message-ID | <cone.1584551939.117857.106569.1004@monster.email-scan.com> |
| In reply to | #72375 |
[Multipart message — attachments visible in raw view] — view raw
Bonita Montero writes:
>>> There's no limitation on my side.
>>
>> ... That's a major limitation of one's ability to understand C++ code.
>
> Everyone without your crystal ball has this limitation.
Too bad, so sad. I guess you'll have to figure it out without having one,
then. Life's so unfair.
>> for (const auto &v:container)
>> {
>> if (v == 0)
>> {
>> ++number_of_zeroes;
>> }
>> }
>
> v can be a type castable to an integer.
Or a suitable operator== overload. Please learn a little bit of C++.
>> Noone really needs to know the type of the container, in this instance.
>
> But in most other instances.
In most other instances almost everyone can figure this out too. Just not
you.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-18 18:27 +0100 |
| Message-ID | <r4tlmd$bhu$1@news.albasani.net> |
| In reply to | #72376 |
>> v can be a type castable to an integer. > Or a suitable operator== overload. Please learn a little bit of C++. If you arguing against yourself there's nothing more to say. > In most other instances almost everyone can figure this out too. > Just not you. I do it like everyone, but this is an unecessary effort.
[toc] | [prev] | [next] | [standalone]
| From | Sam <sam@email-scan.com> |
|---|---|
| Date | 2020-03-18 14:41 -0400 |
| Message-ID | <cone.1584556911.369819.106569.1004@monster.email-scan.com> |
| In reply to | #72377 |
[Multipart message — attachments visible in raw view] — view raw
Bonita Montero writes: >>> v can be a type castable to an integer. > >> Or a suitable operator== overload. Please learn a little bit of C++. > > If you arguing against yourself there's nothing more to say. Here are your toys. You can go home now. >> In most other instances almost everyone can figure this out too. >> Just not you. > > I do it like everyone, but this is an unecessary effort. Not really much of an effort. You just have to know C++.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-18 19:46 +0100 |
| Message-ID | <r4tqb3$2r3$1@news.albasani.net> |
| In reply to | #72379 |
>> I do it like everyone, but this is an unecessary effort. > Not really much of an effort. You just have to know C++. How much depends on the complexity of the type. And if auto is used regulary in a project the effort sums up to a essential part of the work. However, no matter how complex the type is, it's just unecessary.
[toc] | [prev] | [next] | [standalone]
| From | Sam <sam@email-scan.com> |
|---|---|
| Date | 2020-03-18 19:46 -0400 |
| Message-ID | <cone.1584575195.888610.121838.1004@monster.email-scan.com> |
| In reply to | #72381 |
[Multipart message — attachments visible in raw view] — view raw
Bonita Montero writes: >>> I do it like everyone, but this is an unecessary effort. > >> Not really much of an effort. You just have to know C++. > > How much depends on the complexity of the type. And if auto is used > regulary in a project the effort sums up to a essential part of the > work. > However, no matter how complex the type is, it's just unecessary. Not only that, but it is not necessary to also use std::vector, std::list, or any other container in the C++ library. Same thing: none of them are necessary, and it is possible to do everything they do, by yourself. So, please stop using them in your code, because it will be quite unreadable, as a result.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-19 06:41 +0100 |
| Message-ID | <r4v0me$l4i$1@news.albasani.net> |
| In reply to | #72392 |
> Not only that, but it is not necessary to also use std::vector, > std::list, or any other container in the C++ library. ... It doesn't depend on the type of container. It's usually not possible to guess the contained type.
[toc] | [prev] | [next] | [standalone]
| From | Sam <sam@email-scan.com> |
|---|---|
| Date | 2020-03-19 07:02 -0400 |
| Message-ID | <cone.1584615731.939429.132757.1004@monster.email-scan.com> |
| In reply to | #72394 |
[Multipart message — attachments visible in raw view] — view raw
Bonita Montero writes: >> Not only that, but it is not necessary to also use std::vector, std::list, >> or any other container in the C++ library. ... > > It doesn't depend on the type of container. Neither does auto. > It's usually not possible to guess the contained type. Someone who knows C++ does not need to guess. You're just not very good at C++. That's ok. C++ is very complicated. Not everyone can manage to learn it correctly.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-19 12:41 +0100 |
| Message-ID | <r4vlpo$bpv$1@news.albasani.net> |
| In reply to | #72396 |
>> It's usually not possible to guess the contained type. > Someone who knows C++ does not need to guess. You're just not very good > at C++. ... When you didn't write the code you usually have to check the type of the container. When you haven't looked at the code for a long time you might also.
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2020-03-19 06:10 -0700 |
| Message-ID | <7f7162db-bce0-4c00-aeb7-4ec99ba6ce41@googlegroups.com> |
| In reply to | #72397 |
On Thursday, 19 March 2020 13:41:55 UTC+2, Bonita Montero wrote:
> >> It's usually not possible to guess the contained type.
>
> > Someone who knows C++ does not need to guess. You're just not very good
> > at C++. ...
>
> When you didn't write the code you usually have to check the
> type of the container. When you haven't looked at the code for
> a long time you might also.
If you know so well C++ then tell us how you conclude the type of
container from following code:
for (std::pair<std::string, int> e : container) {
std::cout << e.first << ": " << e.second << '\n';
}
It works with raw array of pairs, most of standard library
containers and containers from libraries like boost
that allow to have elements of type pair. So if container's
type matters then you have to check it anyway to understand
the code.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-19 14:15 +0100 |
| Message-ID | <r4vr9p$a5d$1@news.albasani.net> |
| In reply to | #72406 |
> If you know so well C++ then tell us how you conclude the type of
> container from following code:
> for (std::pair<std::string, int> e : container) {
> std::cout << e.first << ": " << e.second << '\n';
> }
You don't need it to know in every caser , but at least you
know the type of its entities; which you don't know with auto.
[toc] | [prev] | [next] | [standalone]
| From | Sam <sam@email-scan.com> |
|---|---|
| Date | 2020-03-19 19:23 -0400 |
| Message-ID | <cone.1584660190.236924.150866.1004@monster.email-scan.com> |
| In reply to | #72397 |
[Multipart message — attachments visible in raw view] — view raw
Bonita Montero writes: >>> It's usually not possible to guess the contained type. > >> Someone who knows C++ does not need to guess. You're just not very good at >> C++. ... > > When you didn't write the code you usually have to check the > type of the container. When you haven't looked at the code for > a long time you might also. But if you know C++, and the code was well-written, even if it was well- written by someone else you rarely need to do that. But only as long as you actually know C++.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-20 09:18 +0100 |
| Message-ID | <r51u9b$9ke$1@news.albasani.net> |
| In reply to | #72411 |
>> When you didn't write the code you usually have to check the >> type of the container. When you haven't looked at the code for >> a long time you might also. > But if you know C++, and the code was well-written, even if it > was well-written by someone else you rarely need to do that. You know it only if you read the part where container was defined or declared. That's often superfluous if you don't use auto.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2020-03-20 05:31 -0700 |
| Message-ID | <cbd08491-ce18-47f3-8ccd-a67626e19635@googlegroups.com> |
| In reply to | #72414 |
On Friday, March 20, 2020 at 4:19:00 AM UTC-4, Bonita Montero wrote: > >> When you didn't write the code you usually have to check the > >> type of the container. When you haven't looked at the code for > >> a long time you might also. > > > But if you know C++, and the code was well-written, even if it > > was well-written by someone else you rarely need to do that. > > > You know it only if you read the part where container was defined > or declared. That's often superfluous if you don't use auto. If know C++, you often don't need to know the exact type, and therefore don't need to read the part where the container was defined or declared. That's particularly true if, as specified, the code was well-written.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2020-03-20 13:40 +0100 |
| Message-ID | <r52djc$9td$1@news.albasani.net> |
| In reply to | #72415 |
> If know C++, you often don't need to know the exact type, and > therefore don't need to read the part where the container was > defined or declared. ... Usually not.
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2020-03-20 08:50 -0700 |
| Message-ID | <0e3656df-8630-4c34-a986-457a394e7e5b@googlegroups.com> |
| In reply to | #72416 |
On Friday, 20 March 2020 14:40:21 UTC+2, Bonita Montero wrote: > On Friday, 20 March 2020 14:31:27 UTC+2, James Kuyper wrote: > > > If know C++, you often don't need to know the exact type, and > > therefore don't need to read the part where the container was > > defined or declared. That's particularly true if, as specified, > > the code was well-written. > > Usually not. We have indeed seen that your code is usually not well written, but ... it is not fault of ours. Try harder?
[toc] | [prev] | [next] | [standalone]
| From | Daniel <danielaparker@gmail.com> |
|---|---|
| Date | 2020-03-20 09:30 -0700 |
| Message-ID | <4cec3c81-c988-47a7-9dee-f4158a20a46a@googlegroups.com> |
| In reply to | #72417 |
On Friday, March 20, 2020 at 11:51:12 AM UTC-4, Öö Tiib wrote:
> On Friday, 20 March 2020 14:40:21 UTC+2, Bonita Montero wrote:
> > On Friday, 20 March 2020 14:31:27 UTC+2, James Kuyper wrote:
> >
> > > If know C++, you often don't need to know the exact type, and
> > > therefore don't need to read the part where the container was
> > > defined or declared. That's particularly true if, as specified,
> > > the code was well-written.
> >
> > Usually not.
>
> We have indeed seen that your code is usually not well written,
> but ... it is not fault of ours.
Nonetheless, Bonita's point, that while usually not necessary to know the
exact type, sometime it is, is valid. Looking only at
for (const auto &v:container)
{
without knowing more about the container, it is not possible to know
by inspection whether type deduction rules via auto will do the right
thing.
Daniel
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2020-03-20 10:13 -0700 |
| Message-ID | <908f81dc-f16d-4689-80e2-c67219ee269c@googlegroups.com> |
| In reply to | #72418 |
On Friday, 20 March 2020 18:31:12 UTC+2, Daniel wrote:
> On Friday, March 20, 2020 at 11:51:12 AM UTC-4, Öö Tiib wrote:
> > On Friday, 20 March 2020 14:40:21 UTC+2, Bonita Montero wrote:
> > > On Friday, 20 March 2020 14:31:27 UTC+2, James Kuyper wrote:
> > >
> > > > If know C++, you often don't need to know the exact type, and
> > > > therefore don't need to read the part where the container was
> > > > defined or declared. That's particularly true if, as specified,
> > > > the code was well-written.
> > >
> > > Usually not.
> >
> > We have indeed seen that your code is usually not well written,
> > but ... it is not fault of ours.
>
> Nonetheless, Bonita's point, that while usually not necessary to know the
> exact type, sometime it is, is valid.
It was not the point, the point was that it is *usually* important
to explicitly tell exact type of container and exact type of the
element of it. While more common in bad code is that the container's
and its element's types are very well known since both are stuttered
explicitly both in types and in names of variables all over the place
ad nausea.
> Looking only at
>
> for (const auto &v:container)
> {
>
> without knowing more about the container, it is not possible to know
> by inspection whether type deduction rules via auto will do the right
> thing.
And that is the other property of bad code, things named "iter", "ptr",
"data", "buf", "container" and other such "foo" and "poo".
Like I already wrote here you wont be in any better understanding from:
for (std::pair<std::string, int> e : container) {
std::cout << e.first << ": " << e.second << '\n';
}
To what bonita replied that at least you know that it is
std::pair<std::string, int>. So what? The code is still bad to read.
[toc] | [prev] | [next] | [standalone]
| From | Daniel <danielaparker@gmail.com> |
|---|---|
| Date | 2020-03-20 10:36 -0700 |
| Message-ID | <dc422754-6ab6-4eb6-ac30-4efbeeceff11@googlegroups.com> |
| In reply to | #72420 |
On Friday, March 20, 2020 at 1:13:35 PM UTC-4, Öö Tiib wrote:
>
> And that is the other property of bad code, things named "iter", "ptr",
> "data", "buf", "container" and other such "foo" and "poo".
I would use "it", for a local iterator variable :-) Also i/j/k for indices.
> Like I already wrote here you wont be in any better understanding from:
>
> for (std::pair<std::string, int> e : container) {
> std::cout << e.first << ": " << e.second << '\n';
> }
>
I disagree. From that, you _know_ that e is not a proxy type.
Daniel
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2020-03-21 12:06 +1300 |
| Message-ID | <hdl0iqF9v62U2@mid.individual.net> |
| In reply to | #72422 |
On 21/03/2020 06:36, Daniel wrote:
> On Friday, March 20, 2020 at 1:13:35 PM UTC-4, Öö Tiib wrote:
>>
>> And that is the other property of bad code, things named "iter", "ptr",
>> "data", "buf", "container" and other such "foo" and "poo".
>
> I would use "it", for a local iterator variable :-) Also i/j/k for indices.
One of the first things I encourage my peers to change (and certainly
the first thing I change) when modernising a loop is the iterator
variable name. Using the likes of "it" or "i" may have been natural
before, where the variable was an iterator, but with a ranged for the
variable as a type and should be maned as such. So we have the likes of
for( const auto& line : lines )
rather than
for( std::vector<std::string>::const_iterator it = lines.begin();
it != lines.end(); ++it )
--
Ian.
[toc] | [prev] | [next] | [standalone]
| From | Öö Tiib <ootiib@hot.ee> |
|---|---|
| Date | 2020-03-20 16:37 -0700 |
| Message-ID | <25170511-fe2f-4125-854f-8267a63fe048@googlegroups.com> |
| In reply to | #72422 |
On Friday, 20 March 2020 19:36:35 UTC+2, Daniel wrote:
> On Friday, March 20, 2020 at 1:13:35 PM UTC-4, Öö Tiib wrote:
> >
> > And that is the other property of bad code, things named "iter", "ptr",
> > "data", "buf", "container" and other such "foo" and "poo".
>
> I would use "it", for a local iterator variable :-) Also i/j/k for indices.
Good idea, "it" instead of "iter" saves whole whopping 2 characters from:
std::vector<std::pair<std::string, int>>::const_iterator it
= container.begin();
> > Like I already wrote here you wont be in any better understanding from:
> >
> > for (std::pair<std::string, int> e : container) {
> > std::cout << e.first << ": " << e.second << '\n';
> > }
> >
> I disagree. From that, you _know_ that e is not a proxy type.
That does not grant me any understanding. I still do _not_ know
if it is copy of object or implicit conversion of it. Ironically
from "auto e" I would at least know that it is copy. Bad code stays
bad.
[toc] | [prev] | [next] | [standalone]
Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7 Next page →
Back to top | Article view | comp.lang.c++
csiph-web