NRVO是否也适用于协程?

问题描述 投票:1回答:1

在下面的示例中,根据this article保证NRVO(命名返回值优化)]

std::string f()
{
    std::string str;

    return str; // NVRO is guaranteed here!
}

但是,请考虑:

task<std::string> f()
{
    std::string str;

    co_return str; // Is NVRO also guaranteed here?
}

在下面的示例中,根据本文保证NRVO(命名返回值优化):std :: string f(){std :: string str; return str; //这里保证NVRO! }但是,...

c++ optimization standards c++20 c++-coroutine
1个回答
6
投票

我知道自C ++ 17起,NRVO(命名返回值优化)是必需的。

© www.soinside.com 2019 - 2024. All rights reserved.