In C++0x, is it legal / expected that some classes can be copied but not moved? I'm looking at implementing a heterogenous class that resizes, and I'm not sure I could handle it if some classes needed copying and some needed moving.
Press and hold the Ctrl key while you drag and drop to always copy. Press and hold the Shift key while you drag and drop to always move.
Let's start with the most basic move when it comes to file handling. Drag and drop a file on the same drive on your Mac. When you do that, your computer will automatically move that file rather than make a copy of it. Click on the file you'd like to move to select it.
If we are cutting(moving) within a same disk, then it will be faster than copying because only the file path is modified, actual data is on the disk. If the data is copied from one disk to another, it will be relatively faster than cutting because it is doing only COPY operation.
Fortunately, you can easily fix it without having to restart your computer or configure your system settings. In File Explorer, click any file or folder and hold the left button on your mouse. Then, press the Esc key. Now, try dragging and dropping again.
Yes, it's legal for a class to be copyable but not movable:
class MyClass {
public:
/* Copyable... */
MyClass(const MyClass&);
MyClass& operator= (const MyClass&);
/* ... but not movable. */
MyClass(MyClass&&) = delete;
MyClass& operator= (MyClass&&) = delete;
};
However, I can't think of a good reason as to why anyone would want to do this. Knowing C++ coders (like me!) though, I think that you should anticipate that this might come up.
Out of curiosity, what code are you relying on that would break if a class was copyable but not movable?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With