move

The efficient way to write move copy and move assignment constructors

北城余情 提交于 2019-12-01 04:55:29
问题 Are the following assignment and copy move constructors the most efficient? if anybody have other way please tell me? I mean what bout std::swap? and calling assignment through copy constructor is safe in the code below? #include <iostream> #include <functional> #include <algorithm> #include <utility> using std::cout; using std::cin; using std::endl; using std::bind; class Widget { public: Widget(int length) :length_(length), data_(new int[length]) { cout<<__FUNCTION__<<"("<<length<<")"<<endl

C# Form Move Stopped Event

跟風遠走 提交于 2019-12-01 03:39:25
问题 Is there any event in C# that fires when the form STOPS being moved. Not while its moving. If there is no event for it, is there a way of doing it with WndProc? 回答1: The ResizeEnd event fires after a move ends. Perhaps you could use that. 回答2: This is not a failsafe solution, but it's pure .NET and it's dead simple. Add a timer to your form, set it to a relatively short delay (100-150 ms seemed OK for me). Add the following code for the Form.LocationChanged and Timer.Tick events: private void

How to calculate look at point to move the camera with the mouse in OpenGL/GLUT?

送分小仙女□ 提交于 2019-12-01 01:47:36
This will be confusing for me to explain so please bear with me. I've already implemented most type of movements and rotations in my camera class, everything is working with the keyboard, now I want to implement the mouse. I capture the mouse movement like this: #define SENSITIVITY 25.0f void main(void) { (...) glutPassiveMotionFunc(processPassiveMotion); glutWarpPointer(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); glutSetCursor(GLUT_CURSOR_NONE); (...) } void processPassiveMotion(int x, int y) { int centerX = WINDOW_WIDTH / 2; int centerY = WINDOW_HEIGHT / 2; int deltaX = -1 * (x - centerX); int

Move iterators for containers?

非 Y 不嫁゛ 提交于 2019-11-30 19:27:45
C++98 containers defined two kinds of iterator, ::iterator s and ::const_iterators . Generally, like this: struct vec{ iterator begin(); const_iterator begin() const; }; In C++11 this part of the design seems to be unchanged. The question is, for consistency and for practical purposes would it make sense to add ::move_iterator s as well? or it an overkill. I can imagine that an rvalue container maybe have their elements moved if possible. class vec{ iterator begin() &; const_iterator begin() const&; move_iterator begin() &&; }; If I understand correctly, it could be implemented like this in

Android RecyclerView Duplicate Item When Scrolling

假装没事ソ 提交于 2019-11-30 19:22:41
I have a problem in RecyclerView . When I move item in RV and then scroll, saw some items has duplicated. RecyclerView will recycle the view.When you delete data,call notifyItemChanged(pos) or notifyDataSetChanged() method. I know its late but hope it will help someone. Override these two methods in your adapter. @Override public long getItemId(int position) { return position; } @Override public int getItemViewType(int position) { return position; } It is your notifyDataSetChanged() that is the issue. Check that you used it properly. That is: private void parseJsonFeed(JSONArray response) {

Prevent a user from deleting, moving or renaming a file

十年热恋 提交于 2019-11-30 18:25:11
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 reading on it with in the .Net 4.0 library. Does anyone have any advice on utilizing either one and if

make batch file that creates a folder with today's date then moves files from a folder in to that newly created folder

烈酒焚心 提交于 2019-11-30 18:04:09
问题 I need to make a batch file that will make a folder with today's date in month day year format (example 080112). Then once it's created i need to move files from a set folder in to the folder it just created. To be honest i don't know how to make a batch file. 回答1: FOR /f "tokens=2-4 delims=/ " %%i in ('DATE/T') do SET today_fname=%%i%%j%%k cd c:\myfolder\%today_fname% REM This creates a folder named 05242016 in c:\myfolder 回答2: This will show you how to set the date in variables. The rest is

how do i fix: 'access denied' with the move command in windows 7?

余生颓废 提交于 2019-11-30 12:38:43
Hi there i'm using the windows 7 'move' command like so: move /Y "C:\old.sub.folder\folder.i.want.to.move" "F:\new.sub.folder\folder.i.want.to.move" and i keep getting an 'accessed denied' error yet i have full permissions and the folder i'm trying to move isn't open or being uses? a random example trying to move one empty folder to another: http://puu.sh/2Rx6b.png any ideas? thanks Or you could try robocopy with /MOVE argument: robocopy C:\old\folder F:\new\folder /E /MOVE Syntax is: MOVE [/Y| /-Y] [Drive:][Path]Folder1 Folder2 That means, you can rename one folder, but you cannot "move"

Moving all files from one directory to another using Python

别等时光非礼了梦想. 提交于 2019-11-30 12:29:37
问题 I want to move all text files from one folder to another folder using Python. I found this code: import os, shutil, glob dst = '/path/to/dir/Caches/com.apple.Safari/WebKitCache/Version\ 4/Blobs ' try: os.makedirs(/path/to/dir/Tumblr/Uploads) # create destination directory, if needed (similar to mkdir -p) except OSError: # The directory already existed, nothing to do pass for txt_file in glob.iglob('*.txt'): shutil.copy2(txt_file, dst) I would want it to move all the files in the Blob folder.

Best way to write constructor of a class who holds a STL container in C++11

烂漫一生 提交于 2019-11-30 09:24:03
class Foo { std::vector<SomeType> data_; }; Say Foo can only be constructed by make a copy (technically I mean a copy or move) of a std::vector<SomeType> object. What's the best way to write constructor(s) for Foo ? My first feeling is Foo(std::vector<SomeType> data) noexcept : data_(std::move(data)) {}; Using it, construction of an instance takes 0 or 1 times of vector copy, depending on whether the argument for {data} is moveable or not. Your first feeling is good. Strictly speaking it is not optimal. But it is so close to optimal that you would be justified in saying you don't care.