Date: Mon, 20 May 2024 22:51:37 +0200
This feature request could be also made to a standard library function.
// Calls the constructor and a setup function. With guaranteed RVO.
T std::factory<T>(params, ..., setup)
No need for other language changes or any special exception handling.
// usage:
mutex my_mutex(bool cond)
{
return std::factory<mutex>(
[&cond](auto mut) {
if (cond)
mut.lock();
}
);
}
-----Ursprüngliche Nachricht-----
Von:Tiago Freire via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Mo 20.05.2024 11:11
Betreff:Re: [std-proposals] std::elide
An:std-proposals_at_[hidden];
CC:Tiago Freire <tmiguelf_at_[hidden]>;
Or just do this instead:
int main(void)
{
mutex m;
m.lock();
}
Does exactly the same thing, saves on functions calls, don't have to write a function, don't need to add a language feature, don't have to abuse the language, it actually makes sense from what a mutex is, its shorter, concise, transparent, clear.
Some problems don't need solving because they were never problems to begin with.
Received on 2024-05-20 20:51:40