field initializer is not constant g++ 4.8.4

核能气质少年 提交于 2020-02-25 13:14:09

问题


I tried to compile the following code on my laptop, using g++ 4.8.4:

#include <algorithm>
#include <iostream>
#include <initializer_list>
#include <tuple>

struct Storage {
  static const int num_spatial_subset = 8;
  static constexpr std::initializer_list<std::initializer_list<double>> vectors{ {0,0,0}, 
      {0,1,0}, 
      {0,0,1}, 
      {1,1,0}, 
      {1,0,1}, 
      {0,1,1}, 
      {1,0,0}, 
      {1,1,1} };
  double storage[num_spatial_subset][vectors.size()];
};


int main()
{
}

And I got this error message:

error: field initializer is not constant
constexpr std::initializer_list< std::initializer_list<double> > vectors{ {0,0,0}, {0,1,0}, {0,0,1}, {1,1,0}, {1,0,1}, {0,1,1}, {1,0,0}, {1,1,1} };

However, I copy/paste the same code on coliru (g++ 6.1.0), with the same compilation parameters and it worked.

Can someone tells me what is wrong please ?

Thank you.


回答1:


Actually, as pointed out by Chris and Baum, updating to g++ 4.9 fixed it.



来源:https://stackoverflow.com/questions/37758382/field-initializer-is-not-constant-g-4-8-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!