- What a bug - 4 Updates
- Sieve of Eratosthenes - 15 Updates
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 07:35PM +0200 I checked for some commandline options and I thought it would be the best to map that through an unordered_map. I extracted this from my application in the below code. #include <Windows.h> #include <iostream> #include <variant> #include <unordered_map> using namespace std; int wmain( int argc, wchar_t **argv ) { static unordered_map<wchar_t const *, DWORD> const opts = { { L"--idle", IDLE_PRIORITY_CLASS }, { L"--below", BELOW_NORMAL_PRIORITY_CLASS }, { L"--above", ABOVE_NORMAL_PRIORITY_CLASS }, { L"--high", HIGH_PRIORITY_CLASS }, { L"--realtime", REALTIME_PRIORITY_CLASS } }; auto mappedPrio = opts.find( "--high" ); if( mappedPrio == opts.end() ) return -1; return 0; } Why does my code have a bug and why doesn't mappedPrio point to end() at the end? |
"Alf P. Steinbach" <alf.p.steinbach@gmail.com>: Sep 01 11:09PM +0200 On 2023-09-01 7:35 PM, Bonita Montero wrote: > } > Why does my code have a bug and why doesn't mappedPrio > point to end() at the end? How did you get that to compile? With the compilation-spoiler fixed and the `-1` replaced with either `E_FAIL` or `EXIT_FAILURE` (for the latter include `<stdlib.h>`), the problem you're /probably/ talking about is why it doesn't work with your setup to compare pointers to string literals. That's because the Holy Standard does not require string pooling. An easy fix is to use `wstring_view` as key (for that include `<string_view>`). - Alf |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Sep 01 02:50PM -0700 On 9/1/2023 10:35 AM, Bonita Montero wrote: > } > Why does my code have a bug and why doesn't mappedPrio > point to end() at the end? Try something like: ___________________________ #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"); if(mapped_opt == opts.end()) { std::cout << "ahhh, shit!!!" << std::endl; return EXIT_FAILURE; } std::cout << mapped_opt->first << ", " << mapped_opt->second << std::endl; return EXIT_SUCCESS; } ___________________________ ? |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Sep 01 02:52PM -0700 On 9/1/2023 2:09 PM, Alf P. Steinbach wrote: > `E_FAIL` or `EXIT_FAILURE` (for the latter include `<stdlib.h>`), the > problem you're /probably/ talking about is why it doesn't work with your > setup to compare pointers to string literals. Yup. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 05:35AM +0200 Am 31.08.2023 um 22:33 schrieb Ben Bacarisse: >> on a Skylake CPU with g++ 12 and -march=native. My code runs about 0.9s, >> your code takes 5.26s. Any questions ? > Is the 1E3 a typo? Yes, 1E8. |
Muttley@dastardlyhq.com: Sep 01 10:26AM On Thu, 31 Aug 2023 17:50:24 +0200 >> the software. Its highly I/O bound. >Read the Wikipedia article about HFC then you won't need to elaborate >everything by your own ideas. I worked in finance for almost 10 years and was involved in writing the network layer to link a particular bank to a number of stock exchanges so I do know what I'm talking about. The microsecond delays in software are statistical noise compared to the millisecond delays on network connections. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 12:59PM +0200 > I worked in finance for almost 10 years and was involved in writing the > network layer to link a particular bank to a number of stock exchanges so > I do know what I'm talking about. ... Certainly not. With high freqency trading sometimes even FPGAs and overclocked CPUs are used. You can verify that easily. My employer has a server with a server attached to a switch which has a further 10GbE link to the worlds largest internet exchange (DE-CIX). We're 250km away from Frankfurt, where the DE-CIX resudes. |
Muttley@dastardlyhq.com: Sep 01 12:30PM On Fri, 1 Sep 2023 12:59:53 +0200 >> I do know what I'm talking about. ... >Certainly not. With high freqency trading sometimes even FPGAs and >overclocked CPUs are used. You can verify that easily. My employer So what? Network delays are still 99.9% of any delay in the process. If people are using those then thats probably for real time processing of market status, not for spot trading. Not that it'll do them any good. People having been trying to write algorithms to predict the market almost since computers were invented and none of them have succeeded to any great extent. >has a server with a server attached to a switch which has a further >10GbE link to the worlds largest internet exchange (DE-CIX). We're >250km away from Frankfurt, where the DE-CIX resudes. And? |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 03:33PM +0200 > So what? Network delays are still 99.9% of any delay in the process. You make up your own mind instead of reading Wikipedia. |
Muttley@dastardlyhq.com: Sep 01 01:49PM On Fri, 1 Sep 2023 15:33:46 +0200 >Am 01.09.2023 um 14:30 schrieb Muttley@dastardlyhq.com: >> So what? Network delays are still 99.9% of any delay in the process. >You make up your own mind instead of reading Wikipedia. I think my first hand experience actually working on these systems trumps anything in wikipedia, but hey, what would I know compared to a genius like you. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 03:59PM +0200 >> You make up your own mind instead of reading Wikipedia. > I think my first hand experience actually working on these systems trumps > anything in wikipedia, but hey, what would I know compared to a genius like you. I guess youre not professionally programming at all according to the n00b-questions you ask for sometimes. |
Muttley@dastardlyhq.com: Sep 01 02:03PM On Fri, 1 Sep 2023 15:59:55 +0200 >you. >I guess youre not professionally programming at all >according to the n00b-questions you ask for sometimes. "n00b"? Wow, you're so L33t. The fact that you believe no ones experience except yours counts for anything says a whole lot about you and its not good. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 04:15PM +0200 > The fact that you believe no ones experience except yours counts > for anything says a whole lot about you and its not good. No, you constantly feel offended by statements from me that you always have to go one step further. That you should have done the same thing as me, especially in a field in which only a few work, is simply very unlikely. It's much more likely that you'll want to put yourself above me again. |
Muttley@dastardlyhq.com: Sep 01 02:39PM On Fri, 1 Sep 2023 16:15:09 +0200 >> for anything says a whole lot about you and its not good. >No, you constantly feel offended by statements from me that you >always have to go one step further. That you should have done the I simply comment on your code and yes, sarcastically if I think it merits it. If you don't want people commenting on your code then don't bloody post it! Unless you only want the fawning adulation you clearly think you deserve but you can forget about that pal. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 04:59PM +0200 > If you don't want people commenting on your code then don't bloody post it! You don't even read it as seen from that you noticed my usage of the comma-oerator very late. And according to your n00b C++ questions you don't understand it. |
Muttley@dastardlyhq.com: Sep 01 03:01PM On Fri, 1 Sep 2023 16:59:21 +0200 >> If you don't want people commenting on your code then don't bloody post it! >You don't even read it as seen from that you noticed my usage >of the comma-oerator very late. First time I bothered to look. I won't be bothering again. >And according to your n00b C++ questions you don't understand it. Whatever you say genius. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 05:05PM +0200 >> You don't even read it as seen from that you noticed my usage >> of the comma-oerator very late. > First time I bothered to look. I won't be bothering again. Exactly what I said: you comment my code without having read it. >> And according to your n00b C++ questions you don't understand it. > Whatever you say genius. I'm just calm, sane and intelligent. |
Muttley@dastardlyhq.com: Sep 01 03:08PM On Fri, 1 Sep 2023 17:05:03 +0200 >>> And according to your n00b C++ questions you don't understand it. >> Whatever you say genius. >I'm just calm, sane and intelligent. A psychology student could write their thesis about you. |
Bonita Montero <Bonita.Montero@gmail.com>: Sep 01 05:15PM +0200 >>> Whatever you say genius. >> I'm just calm, sane and intelligent. > A psychology student could write their thesis about you. Not at all, I just feel good. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment