开发者

Function returning constexpr does not compile

开发者 https://www.devze.com 2023-04-13 00:55 出处:网络
Why doesn\'t this compile: Could there be a problem with a string as a return type? constexpr开发者_开发问答 std::string fnc()

Why doesn't this compile:

Could there be a problem with a string as a return type?

constexpr开发者_开发问答 std::string fnc()
{
    return std::string("Yaba");
}


The constructor of std::string that takes a pointer to char is not constexpr. In constexpr functions you can only use functions that are constexpr.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号