Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #91536
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Subject | Re: What a bug |
| Newsgroups | comp.lang.c++ |
| References | <uct7ch$3uope$1@dont-email.me> <uctmag$1a28$1@dont-email.me> <ucud4u$a111$1@dont-email.me> <ud3154$13irg$2@dont-email.me> |
| Message-ID | <VMlJM.780913$mPI2.515002@fx15.iad> (permalink) |
| Organization | UsenetServer - www.usenetserver.com |
| Date | 2023-09-04 14:24 +0000 |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>On 9/1/2023 9:19 PM, Bonita Montero wrote:
>> Am 01.09.2023 um 23:50 schrieb Chris M. Thomasson:
>>
>>> Try something like:
>>
>> I know that I could have done that easier, but I wanted to know
>> where's the bug and why my example does find the key value anyway.
>>
>>> ___________________________
>>> #include <iostream>
>>> #include <unordered_map>
>>> #include <string>
>>> #include <cstdlib>
>>>
>>>
>>> int main()
>>> {
>>> static std::unordered_map<std::string, long> opts = {
>>> {"--idle", 0 },
>>> {"--below", 1 },
>>> {"--above", 2 },
>>> {"--high", 3 },
>>> {"--realtime", 4 }
>>> };
>>>
>>> auto mapped_opt = opts.find("--realtime");
>>
>> The problem here is that each find creates a string-object,
>> which is rather slow.
>
>Right. Afaict, there is a way to create the strings on the stack and use
>a little adapter logic to make it work with std::unordered_map. So, no
>dynamic allocation.
Or just use getopt_long() with UTF-8 strings.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-01 19:35 +0200
Re: What a bug "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-09-01 23:09 +0200
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-01 14:52 -0700
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-02 06:23 +0200
Re: What a bug Muttley@dastardlyhq.com - 2023-09-02 10:25 +0000
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-02 12:56 +0200
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-02 14:35 +0200
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-02 14:41 +0200
Re: What a bug Muttley@dastardlyhq.com - 2023-09-02 15:30 +0000
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-02 18:10 +0200
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-01 14:50 -0700
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-02 06:19 +0200
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-03 15:25 -0700
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-04 04:53 +0200
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-03 20:01 -0700
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-04 06:59 +0200
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-04 11:11 +0200
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-04 18:48 -0700
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-14 16:27 -0700
Re: What a bug scott@slp53.sl.home (Scott Lurndal) - 2023-09-04 14:24 +0000
Re: What a bug "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-18 16:20 -0700
Re: What a bug Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-09-04 18:43 -0400
Re: What a bug red floyd <no.spam.here@its.invalid> - 2023-09-04 17:36 -0700
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-05 05:49 +0200
Re: What a bug Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-09-06 12:00 -0400
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-06 19:46 +0200
Re: What a bug Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-09-06 14:44 -0400
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-07 04:51 +0200
Re: What a bug Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-09-06 23:54 -0400
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-07 06:58 +0200
Re: What a bug Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-09-07 11:08 -0400
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-07 17:56 +0200
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-07 18:04 +0200
Re: What a bug Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-09-07 19:35 -0400
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-07 17:46 +0200
Re: What a bug jak <nospam@please.ty> - 2023-09-02 23:15 +0200
Re: What a bug jak <nospam@please.ty> - 2023-09-03 23:17 +0200
Re: What a bug Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-03 17:37 -0700
Re: What a bug jak <nospam@please.ty> - 2023-09-05 11:01 +0200
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-05 11:12 +0200
Re: What a bug Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-05 03:04 -0700
Re: What a bug jak <nospam@please.ty> - 2023-09-07 01:18 +0200
Re: What a bug James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-09-08 00:09 -0400
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-05 11:11 +0200
Re: What a bug red floyd <no.spam.here@its.invalid> - 2023-09-05 20:53 -0700
Re: What a bug Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-05 21:14 -0700
Re: What a bug red floyd <no.spam.here@its.invalid> - 2023-09-06 17:51 -0700
Re: What a bug Bonita Montero <Bonita.Montero@gmail.com> - 2023-09-06 06:49 +0200
csiph-web