Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85794
| From | "Alf P. Steinbach" <alf.p.steinbach@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: map[string_view] not compiling |
| Date | 2022-08-03 13:38 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <tcdmmu$26sqq$1@dont-email.me> (permalink) |
| References | <tc8epl$t0hn$1@dont-email.me> <tcdff0$25305$1@dont-email.me> <tcdjrf$1dc1$1@gioia.aioe.org> |
On 3 Aug 2022 12:49, Juha Nieminen wrote: > Alf P. Steinbach <alf.p.steinbach@gmail.com> wrote: >> using std::less, >> std::map, >> std::out_of_range, >> std::string, >> std::string_view, >> std::forward; > > I love how you use 92 characters (and six lines of code) in order to > avoid writing "std::" three times, which would be a total of 15 characters. > Thus you saved a total of -77 characters and -6 lines of code. Noted, that the measure of number of letters is important to you. >> private map<Key_, Item_, less<>> >> using Std_map = map<Key, Item, less<>>; >> throw out_of_range( "const-Map_::operator[] - no such > > While, at the same time, making the code less readable. While at odds with objective reality (e.g. amount of text to parse), and also at odds with your own above stated preference for succinct code, i.e. contradicting yourself, here you're unfortunately in line with a great many C++ programmers which by now may even constitute a majority. But considering that also a majority of humans on Earth, near 90% I think the number was, claim that they are religious, i.e. that they have various serious delusions such as the common belief in personal telepathic communication with an invisible alien in outer space, I would not adopt the (probably) herd majority position without at least one reason other than that it is believed by many people. > (Say what you want, but for example mixing "Map_" and "map" in the same > code is confusing. "std::map" would visually distinguish them much better.) > > And why? What for? To this day this is a complete mystery to me. > (I most certainly do not subscribe to the brevity-over-clarity style of > programming.) > > There's also a degree of irony in that "Std_map" name... `Std_map` refers to a distinct specialization of `std::map`. It's objectively much better to name it than to define it repeatedly every place it's used. So there is no irony, even with your preferences. Avoiding repetition is called the DRY principle, Don't Repeat Yourself, yielding more DRY code. There are many advantages so the principle's goodness is commonly accepted. Wikipedia has a page about it at <url: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself>. - Alf
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
map[string_view] not compiling Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-01 14:52 +0300
Re: map[string_view] not compiling Bo Persson <bo@bo-persson.se> - 2022-08-01 14:32 +0200
Re: map[string_view] not compiling Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-01 17:11 +0300
Re: map[string_view] not compiling Öö Tiib <ootiib@hot.ee> - 2022-08-01 13:30 -0700
Re: map[string_view] not compiling Bo Persson <bo@bo-persson.se> - 2022-08-01 23:23 +0200
Re: map[string_view] not compiling Öö Tiib <ootiib@hot.ee> - 2022-08-01 22:52 -0700
Re: map[string_view] not compiling Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-08-04 08:31 -0700
Re: map[string_view] not compiling "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-08-03 11:34 +0200
Re: map[string_view] not compiling Juha Nieminen <nospam@thanks.invalid> - 2022-08-03 10:49 +0000
Re: map[string_view] not compiling "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-08-03 13:38 +0200
Re: map[string_view] not compiling Juha Nieminen <nospam@thanks.invalid> - 2022-08-04 06:16 +0000
Re: map[string_view] not compiling Paavo Helde <eesnimi@osa.pri.ee> - 2022-08-03 14:43 +0300
Re: map[string_view] not compiling "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-08-03 13:56 +0200
csiph-web