static compile time table with floating point values

前端 未结 2 327
你的背包
你的背包 2021-01-14 21:38

Is it possible to generate an array at compile time, like in this nice answer of G. Fritzsche: Georg Fritzsche

but with floating point values?

2条回答
  •  旧巷少年郎
    2021-01-14 22:02

    It wasn't possible in standard-compliant C++ when Georg wrote his answer, but with C++11 we can now do compile-time computation with floating-point and other numeric types.

    The trick is to use constexpr functions instead of non-type template parameters.

提交回复
热议问题