Sujet : Re: Threads across programming languages
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.c++ comp.lang.cDate : 03. May 2024, 08:05:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v122b4$db4v$2@raubtier-asyl.eternal-september.org>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Mozilla Thunderbird
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.