看来此代码(所以它编译罚款),我要问这里是:是否有保证的sizeof(STD ::阵列)是一样的sizeof(equivalent_Carray)?std :: array <T, N>的大小是否保证等于T [N]的大小?
struct MyClass {
std::array<float, 4> arr;
float carr[4];
std::array<float, 4> cfunction() {
std::array<float, sizeof(carr)/sizeof(float)> out;
return out;
}
std::array<float, 4> function() {
// Is this guaranteed to be the same as sizeof(carr)/sizeof(float)??
std::array<float, sizeof(arr)/sizeof(float)> out;
std::cout << sizeof(arr);
return out;
}
};
int main()
{
MyClass obj;
obj.function();
}
请提出一个有用的问题标题。 –