move

Prevent a user from deleting, moving or renaming a file

烈酒焚心 提交于 2020-01-21 04:16:28
问题 What I am trying to do is while my program is using a file, I want to keep the user from renaming, deleting, or moving the file (well... a move is a delete and a create at a different location according to Windows FileSystemWatcher, but I digress). It has been suggested that I use FileStream.Lock or use a Mutex. However, FileStream.Lock seems only to prevent the file from being modified which I am trying to allow . Also, I am very unsure as to if a mutex can lock a file, although I am still

C++, std::move

送分小仙女□ 提交于 2020-01-21 01:10:07
0. std::move is used to indicate that an object may be "removed from", allowing the efficient transfer of resources from t to another object. 1. Examples: #include <utility> string str = "hello"; string str2 = std::move(str); // transfer and str2 is "hello" cout << str << endl; // str is empty now 来源: https://www.cnblogs.com/sarah-zhang/p/12219961.html

Cannot move std::any

旧街凉风 提交于 2020-01-16 18:02:06
问题 The following code using vptr = std::vector<std::unique_ptr<int>>; auto m = std::unordered_map<int, std::any>{}; m.try_emplace(0, move(vptr{})); Fails to compile, complaining about using of deleted copy constructor of unique_ptr . After replacing std::any with vptr in template argument this code compiles, so the issue is clearly with any How can I force std::any to be moved instead of copied? 回答1: The problem is not moving std::any, it's that std::any itself does not support move-only types

Cannot move std::any

坚强是说给别人听的谎言 提交于 2020-01-16 18:01:09
问题 The following code using vptr = std::vector<std::unique_ptr<int>>; auto m = std::unordered_map<int, std::any>{}; m.try_emplace(0, move(vptr{})); Fails to compile, complaining about using of deleted copy constructor of unique_ptr . After replacing std::any with vptr in template argument this code compiles, so the issue is clearly with any How can I force std::any to be moved instead of copied? 回答1: The problem is not moving std::any, it's that std::any itself does not support move-only types

Setting X Coordinate from Mouse Location

吃可爱长大的小学妹 提交于 2020-01-15 12:20:38
问题 i have a darkBlueRect rectangle sprite and a copy of the same sprite with a larger scale and a lighter color - lightBlueRect . i'm attempting to shift the location of the lightBlueRect according to the mouse.x location when the mouse is moving over the darkBlueRect . this way if the mouse is on the right of the darkBlueRect than the location of the scaled up lightBlueRect will be on the opposite side and shifted towards the left proportionate to the mouse position and scale. in addition, the

Deleting move constructor and constructing object from rvalue

妖精的绣舞 提交于 2020-01-15 08:08:40
问题 I'm trying to understand Item 17 from "Effective Modern C++" about special member function generation so I was trying some examples and am trying to reason about some behavior. In the book it says: ..that when I refer to a move operation move-constructing or move-assigning a data member or base class, there is no guarantee that a move will actually take place. “Memberwise moves” are, in reality, more like memberwise move requests, because types that aren’t move-enabled (i.e., that offer no

Java - How to move a file into a zip file?

守給你的承諾、 提交于 2020-01-13 18:05:38
问题 That's it. I have a text file, and I need to move it to a (existing) Zip File in a given directory. File file = new File("C:\\afolder\\test.txt"); File dir = new File(directoryToGo+"existingzipfile.zip"); boolean success = file.renameTo(new File(dir, file.getName())); But it does not work. Is there a way to move a file into a existing Zip File? Thank you. 回答1: Hmm you could use something like: public static void addFilesToExistingZip(File zipFile, File[] files) throws IOException { // get a

Is there a back_inserter variant that takes advantage of move?

爷,独闯天下 提交于 2020-01-13 11:43:08
问题 In generic code I was trying to tell an output iterator (in practice a std::back_inserter_iterator to move a range of elements. To my surprise it looked as if elements were moved in a move-to-back_inserter operation. #include<algorithm> // move #include<iterator> // back_inserter #include<vector> int main(){ std::vector<std::vector<double> > v(10, std::vector<double>(100)); std::vector<std::vector<double> > w; assert( not v[0].empty() and w.size() == 0 ); std::copy(v.begin(), v.end(), std:

Is there a back_inserter variant that takes advantage of move?

谁说我不能喝 提交于 2020-01-13 11:43:08
问题 In generic code I was trying to tell an output iterator (in practice a std::back_inserter_iterator to move a range of elements. To my surprise it looked as if elements were moved in a move-to-back_inserter operation. #include<algorithm> // move #include<iterator> // back_inserter #include<vector> int main(){ std::vector<std::vector<double> > v(10, std::vector<double>(100)); std::vector<std::vector<double> > w; assert( not v[0].empty() and w.size() == 0 ); std::copy(v.begin(), v.end(), std:

How to move and resize the browser's window in Opera and Chrome?

被刻印的时光 ゝ 提交于 2020-01-11 09:59:54
问题 I was looking for a way to resize and move the browser's window and I've found these: self.resizeTo(w, h) and self.moveTo(x, y) - this seems to work perfectly, but only in Firefox and IE (tested with IE8, I don't know how it works in the previous versions). How can I force the same behavior (resizing and moving) in Opera and Chrome? In these browsers the above solution does not work at all. Just nothing happens and nothing appears in the error console. 回答1: In Opera and Chrome you can use