#include
struct foo
{
int x{0};
foo() noexcept = default;
void f() noexcept(noexcept(std::declval())) {}
};
int main()
Your usage is fine.
int x{0} clearly falls under the category non-static data member with initializer (C++11). declval does not require a complete type--that's kind of the point of it, as explained in this nice exposition. What's left? Compiler bug, I guess. How about this for evidence? Use a complete type z instead of foo in your declval.
#include
struct z{};
struct foo
{
int x{0};
foo() noexcept = default;
void f() noexcept( noexcept( std::declval() ) ) {}
};
int main()
{
}
Clang 4.0.0 on godbolt still errors the same way. Unfortunately I do not have clang 4.0.0 available on a machine to test, so I cannot not say whether it is Clang or godbolt for certain.