【发布时间】:2016-03-27 08:57:24
【问题描述】:
看来这段代码可以工作(所以它编译得很好),我在这里要问的是:是否保证 sizeof(std::array) 与 sizeof(equivalent_Carray) 相同?
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();
}
【问题讨论】:
-
请做一个有用的问题标题。
标签: c++ arrays c++11 c++14 sizeof