GCC constexpr lambdas in constexpr functions and evaluation in compile time
问题 Code first, we have the following piece of code that is used to accumulate a constexpr std::array in compile time: template <typename T, std::size_t N, typename O> constexpr T compile_time_accumulator(const std::array<T, N> const &A, const std::size_t i, const O& op, const T initialValue) { return (i < N) ? op(A[i], compile_time_accumulator(A, i + 1, op, initialValue)) : initialValue; } and the following code example to test/varify it (i.e., that it evaluates in compile time): constexpr std: