Incomplete types as function parameters and return values
问题 The following code compiles successfully both with clang++ 5.0.0 and g++ 7.2 (with the -std=c++17 -Wall -Wextra -Werror -pedantic-errors -O0 compilation flags): struct Foo; struct Bar { Foo get() const; void set(Foo); }; struct Foo { }; Foo Bar::get() const { return {}; } void Bar::set(Foo) { } int main() { Bar bar{}; (void)bar.get(); bar.set(Foo{}); } Is it valid to use incomplete types as function parameters and return values? What does the C++ say on it? 回答1: In a function definition , you