根据 cppref , 在 C++20 中,std::vector::push_back
声明如下:
constexpr void push_back(const T& value);
我无法想象 push_back
的场景应该是 constexpr
.背后的原理是什么?
最佳答案
Is there any rationale behind?
这是提案的摘要。没有单独的理由部分:
P1004R2 Making std::vector constexpr
Abstract
std::vector is not currently constexpr friendly. With the loosening of requirements on constexpr in [P0784R1] and related papers, we can now make std::vector constexpr, and we should in order to support the constexpr reflection effort (and other evident use cases).
关于c++ - 为什么在 C++20 中将 std::vector::push_back 声明为 constexpr?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68094329/