Код: Выделить всё
#include
#include
#include
constexpr std::string str15 {"123456789012345"}; // THIS COMPILES
struct Foo
{
constexpr Foo() : a(6) {
for (int i = 0; i < 8; ++i)
buff[i] = 0;
}
int a;
char buff[8];
};
constexpr void func()
{
constexpr Foo f{}; // THIS COMPILES
constexpr std::string str15 {"123456789012345"}; // THIS DOESN'T COMPILE
}
int main() {
func();
return 0;
}
Код: Выделить всё
'std::string{std::__cxx11::basic_string::_Alloc_hider{((char*)(& str15.std::__cxx11::basic_string::.std::__cxx11::basic_string::::_M_local_buf))}, 15, std::__cxx11::basic_string::{char [16]{'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', 0}}}' is not a constant expression
Код: Выделить всё
constexpr std::string str15 {"123456789012345"}; // THIS COMPILES
Подробнее здесь: https://stackoverflow.com/questions/798 ... c-variable
Мобильная версия