例如,如果我想constexpr std::array<int,100>
在编译时使用 1-300 的所有 3 的倍数进行初始化,我该怎么做?
我的第一个想法是使用 std::generate,例如:
constexpr std::array<int,100> a { std::generate(a.begin(), a.end(), [n=0]()mutable{ return n+=3; });
我收到一个错误,例如<source>:9:52: error: void value not ignored as it ought to be
我不能在这之后使用 std::generate 因为当然,它在那个时候是只读的
谢谢你的帮助