On Thu, Sep 28, 2017 at 4:05 PM, Niall Douglas via Boost
Why... what changed in C++1z that makes the above compile? How can I prevent copying x outside its friend function f in C++1z?
C++ 17 guarantees copy elision in the strong sense.
Note it still can't be copied, but it can be initialised now. So disable non-friend construction to fix.
I see. However, making the constructor private still does not make the compilation fail. The following code compiles fine on clang++ -std=c++1z ... struct x { private: x() {} x(x const&) {} x& operator=(x const&) { return *this; } friend x f(); }; x f() { return x(); } int main() { auto xx = f(); return 0; } Is there any way to make that `auto xx = f()` in main fail at compile time in C++1z? Thanks, --Lorenzo