Warum wird diese statische Elementfunktion von constexpr beim Aufruf nicht als constexpr angesehen?

Warum ist dasconstexpr static member-Funktion, gekennzeichnet durch das//! Nah Kommentar, nicht als @ gesehconstexpr wann angerufen?

struct Item_id
{
    enum Enum
    {
        size, position, attributes, window_rect, max_window_size, _
    };

    static constexpr int n_items_ = _;                          // OK
    constexpr auto member_n_items() const -> int { return _; }  // OK
    static constexpr auto static_n_items() -> int { return _; } // OK
    static constexpr int so_far = n_items_;                     // OK
    #ifndef OUT_OF_CLASS
        static constexpr int bah = static_n_items();            //! Nah.
    #endif
};

constexpr auto n_ids() -> int { return Item_id().member_n_items(); }    // OK

auto main() -> int
{
    #ifdef OUT_OF_CLASS
        static constexpr int bah = Item_id::static_n_items();   // OK
    #endif
}

MinGW g ++ 5.1 berichtet

constexpr.cpp:12:46: error: 'static constexpr int Item_id::static_n_items()' called in a constant expression
     static constexpr int bah = static_n_items();                //! Nah.

Visual C ++ 2015 berichtet

constexpr.cpp(12): error C2131: expression did not evaluate to a constant
constexpr.cpp(12): note: failure was caused by call of undefined function or one not declared 'constexpr'
constexpr.cpp(12): note: see usage of 'Item_id::static_n_items'

Mein Texteditor besteht darauf, dass der Name im Aufruf mit dem Namen in der Funktionsdefinition übereinstimmt.

Es scheint etwas mit unvollständiger Klasse zu tun zu haben, weil mitOUT_OF_CLASS definiert es kompiliert gut.

Aber warum funktioniert dann dasn_items_ Daten funktionieren, und warum eine solche Regel (ergibt für mich keinen Sinn)?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage