5

I have a following piece of C++ code:

template <typename WorkType, int Degree = 2> class PolynomialFunction {
 public:
  static constexpr int kNumberCoefficients[] = { 0, 3, 6, 10, 15 };
  static const int kPolyDimension = kNumberCoefficients[Degree];
  ...
 private:
  WorkType polynom_[kPolyDimension];
  ...

which compiled fine before but suddenly (maybe new compiler) it fails with following errors:

./polynomial_function.h: In instantiation of 'constexpr const int PolynomialFunction::kNumberCoefficients []':
./polynomial_function.h:84:56: required from 'const int PolynomialFunction::kPolyDimension'
./polynomial_function.h:309:35: required from 'class PolynomialFunction'
./segment.h:321:17: required from here
./polynomial_function.h:83:24: error: initializer fails to determine size of 'PolynomialFunction::kNumberCoefficients'
./polynomial_function.h:83:24: error: array must be initialized with a brace-enclosed initializer
./polynomial_function.h: In instantiation of 'class PolynomialFunction':
./segment.h:321:17: required from here

Btw. line 83 is the declaration of 'kNumberCoefficients' and line 309 is the declaration of 'polynom_'. Any ideas why it is failing? Thanks.

quantdev
  • 23,517
  • 5
  • 55
  • 88
Marek
  • 79
  • 1
  • 6

0 Answers0