'function' : 呼叫不會導致常數表達式
備註
宣告為 constexpr 的函式只能呼叫宣告為 constexpr 的其他函式。
範例
下列範例會產生 C2134:
// C2134.cpp
// compile with: /c
int A() {
return 42;
}
constexpr int B() {
return A(); // Error C2134: 'A': call does not result in a constant expression.
}
可能的解決方式:
// C2134b.cpp
constexpr int A() { // add constexpr to A, since it meets the requirements of constexpr.
return 42;
}
constexpr int B() {
return A(); // No error
}