Get the latest tech news
Swift for C++ Practitioners: Move Semantics
Swift for C++ Practitioners, Part 12: Move Semantics
In Swift, there is a standard idiom for correctly handling this: the FileHandle class will make that state private and provide a withXYZ method that gives the value to a closure. With noncopyable types, we can't copy our way out of potential exclusivity violations, so you're likely to encounter more compiler errors intended to guide you to verifiably correct, unique ownership of resources. One side benefit of generalizing a generic function to support non-copyable types is that it guarantees that all copying operations (which can involve reference counting) are completely eliminated.
Or read this on Hacker News