问题
Why is the following not compiling? This is somehow counter-intuitive (not to say constexpr
concepts are confusing):
#include <tuple>
int main() {
constexpr const int a = 0;
static_assert(a == 0, "Wups");
constexpr auto t2 = std::forward_as_tuple(a, a);
}
LIVE
I assumed that a
is a compile-time constant expression which is clearly the case as I can use it in static_assert
.
Background: I wanted to continue with constexpr
tuple of reference to feed to other constexpr
functions to do some compile-time computations
来源:https://stackoverflow.com/questions/59563997/why-is-constexpr-with-stdforward-as-tuple-not-working