mercredi 22 avril 2020

Is it allowed to declare a nested class object outside the scope?

#include <type_traits>

auto f()
{
    struct A { int f() { return 0; } };

    return A();
}

int main()
{
    std::remove_cvref_t<decltype(f())> a;

    return a.f();
}

The code above can be compiled successfully. I just wonder:

Is it legal as per the C++ standard?

Aucun commentaire:

Enregistrer un commentaire