{
return std::begin( { 0.0, 0.3085375, 0.6914625, 0.9331928, 0.9937903, 0.9997674, 0.9999966 } )[ n ];
}
我不确定你同事的这段代码是否肯定能在 编译期计算出来。因为std::begin好像不是constant expression。
https://en.cppreference.com/w/cpp/language/constant_expression 试过了,可以的:std::begin, std::cbegin,标准库对std::begin(std::initializer_list) 进行了特化。
可以用 static_assert 调用到其值,说明是在编译期可计算出来的。
页:
1
[2]