N4140 §5.19/2.3から(強調鉱山)
—未定義の constexpr 関数または 未定義のconstexpr コンストラクターの呼び出し。
§7.1.5/2 以降、constexpr 関数とコンストラクターは暗黙的にインライン化されます。つまり、constexpr 関数が TU で定義されていない場合、コードはコンパイルされません。
N4140 §5.19/2.3から(強調鉱山)
—未定義の constexpr 関数または 未定義のconstexpr コンストラクターの呼び出し。
§7.1.5/2 以降、constexpr 関数とコンストラクターは暗黙的にインライン化されます。つまり、constexpr 関数が TU で定義されていない場合、コードはコンパイルされません。
この箇条書きは欠陥レポート 699によって追加されたものであり、使用前に constexpr 関数またはコンストラクターを定義する必要があります。欠陥レポート7.1.5
では、ルールを示すために次の例が追加されました。
constexpr int square(int x); //OK, declaration
constexpr struct pixel { // error: pixel is a type
int x;
int y;
constexpr pixel(int); // OK, declaration
};
constexpr pixel::pixel(int a)
: x(square(a)), y(square(a)) { } //OK, definition
constexpr pixel small(2); // error: square not defined, so small(2)
// not constant (5.19 [expr.const]), so constexpr not satisfied
constexpr int square(int x) { // OK, definition
return x * x;
}
constexpr pixel large(4); // OK, square defined
このレポートの文言は、欠陥レポート 1365で現在ドラフト規格にある文言に変更されていることに注意してください。