std::mutex f() {return std::mutex{};} // factory function using guarenteed copy elision allows this even though mutex cannot be copied or moved from
int main() {
std::optional m;
m.emplace(f()); //
Подробнее здесь: [url]https://stackoverflow.com/questions/79692517/how-is-it-possible-to-emplace-construct-an-object-from-a-factory-function[/url]
Можно ли извлечь конструкцию объекта из фабричной функции? < /p> [code]std::mutex f() {return std::mutex{};} // factory function using guarenteed copy elision allows this even though mutex cannot be copied or moved from