返回constexpr的函数无法编译

时间:2011-10-15 16:15:50

标签: c++ compiler-errors c++11 constexpr

为什么不编译:
string作为返回类型会出现问题吗?

constexpr std::string fnc()
{
    return std::string("Yaba");
}

1 个答案:

答案 0 :(得分:14)

指向std::string的{​​{1}}构造函数不是char。在constexpr函数中,您只能使用constexpr函数。

相关问题