Deutsch English Français Italiano |
<v122j2$df4p$1@raubtier-asyl.eternal-september.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail From: Bonita Montero <Bonita.Montero@gmail.com> Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: Threads across programming languages Date: Fri, 3 May 2024 09:09:23 +0200 Organization: A noiseless patient Spider Lines: 35 Message-ID: <v122j2$df4p$1@raubtier-asyl.eternal-september.org> References: <GIL-20240429161553@ram.dialup.fu-berlin.de> <v0ogum$1rc5n$1@dont-email.me> <v0ovvl$1ur12$4@dont-email.me> <v0p06i$1uq6q$5@dont-email.me> <v0shti$2vrco$2@raubtier-asyl.eternal-september.org> <v0spsh$31ds4$3@dont-email.me> <v0stic$325kv$3@raubtier-asyl.eternal-september.org> <v0svtn$32o8h$1@dont-email.me> <v0t091$32qj6$1@raubtier-asyl.eternal-september.org> <v0u90h$3c1r5$4@dont-email.me> <v0v28q$3ku1r$1@raubtier-asyl.eternal-september.org> <v1176k$4at1$3@dont-email.me> <v12175$d305$2@raubtier-asyl.eternal-september.org> <v122b4$db4v$2@raubtier-asyl.eternal-september.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 03 May 2024 09:09:23 +0200 (CEST) Injection-Info: raubtier-asyl.eternal-september.org; posting-host="c030ccadbcaefe746bb34fa5f5a5f34a"; logging-data="441497"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/5qH1UwxlGC1HBFi2z+8qMm8f5whDpTc=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:2wLfDLrAaixiuLtg3bUAV1RDQ3k= In-Reply-To: <v122b4$db4v$2@raubtier-asyl.eternal-september.org> Content-Language: de-DE Bytes: 2508 Am 03.05.2024 um 09:05 schrieb Bonita Montero: > Am 03.05.2024 um 08:45 schrieb Bonita Montero: > >> using namespace std; >> >> function<int ()> factory() >> { >> return [] >> { >> static int count = 0; >> return ++count; >> }; >> } > > function<int ()> factory() > { > static auto fn = [] > { > static int count = 0; > return ++count; > }; > return cref( fn ); > } > > Better this, it doesn't allocate external memory for the function<> > object. Or do you mean sth. like this, where each function-object has its own count state: function<int ()> factory() { return [count=0]() mutable { return ++count; }; }