“Default member initializer needed within definition of enclosing class outside of member functions” - is my code ill-formed?

前端 未结 5 1053
别那么骄傲
别那么骄傲 2020-12-05 02:50
#include 

struct foo
{
    int x{0};
    foo() noexcept = default;
    void f() noexcept(noexcept(std::declval())) {}
};

int main()
         


        
5条回答
  •  旧时难觅i
    2020-12-05 03:23

    This is correct syntactical way is I can say.

    #include 
    
    struct foo
    {
        int x{0};
        foo() noexcept {} // = default;
        void f() noexcept(noexcept(std::declval())) {}
    };
    
    int main()
    { 
    }
    

提交回复
热议问题