Questions tagged [move]

Usually refers to move semantics; consider using that tag instead. Move semantics is a programming language feature that allows a copy operation to be replaced by a more efficient "move" when the source object is a temporary or an otherwise expiring object.

move
952 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
1 answer
695 views

Detect use-after-move for global variables

After some effort, I convinced both the clang compiler and clang-tidy (static analyzer) to warn of a use-after-move situation. (see https://stackoverflow.com/a/74250567/225186) int main(int, char**) { ...
alfC's user avatar
  • 15.2k
7 votes
0 answers
3k views

How to set Python console opening position?

How to set the position of the Python console? For example: os.system('mode con: cols=88 lines=30') However, I want to move the window to another location. For example: os.system('mode move: x=88 y=...
Fahri Güreşçi's user avatar
7 votes
1 answer
2k views

SVN history is lost in git

We moved a project from svn to git recently. Before moving to git, some folders were re-organized in svn. Now, git doesnt show the complete history for files in the folders that were moved/re-named ...
crankparty's user avatar
  • 1,240
6 votes
0 answers
156 views

What is best practice for move semantics with virtual functions?

So let's say i have interface: class MyInterface { public: virtual ~MyInterface() = default; virtual void DoSomething(const MyType& a, const MyTypeB& b); }; And the thing i want is to ...
toozyfuzzy's user avatar
  • 1,108
6 votes
1 answer
489 views

How can I keep a reference to something that gets moved?

I have something as the following using rapidjson rapidjson::Value parent; parent.SetObject(); rapidjson::Value child; child.SetObject(); parent.AddMember("child", child, document....
Lord Nikon's user avatar
6 votes
0 answers
685 views

Implementation of push_back via emplace_back

Suppose we want design a container C similar to std::vector. Is it a good idea to implement push_back by calling emplace_back, such as: template <typename T> class C { public: ... ...
Daniel Langr's user avatar
  • 22.8k
4 votes
0 answers
174 views

C++ Initializing unique_ptr in nested map, compilation error?

I understand unique_ptr can only be move constructed and move assigned, but the following code still puzzles me, #include <map> #include <memory> #include <utility> using namespace ...
QnA's user avatar
  • 1,073
4 votes
0 answers
300 views

Movable GtkWindow with "desktop" type hint

I am currently trying to make a window stick in the background and not be iconifiable. My window is undecorated, but has a custom header, so it's still dragable and resizable. This behavior is ...
Marcel's user avatar
  • 1,518
4 votes
0 answers
282 views

Boost variant recursive wrapper with non-copyable type

I am trying to create a variant of non-copyable types possibly using the recursive wrapper, such as in the following code: #include "boost/variant.hpp" using namespace std; using namespace boost; ...
Mirco's user avatar
  • 99
4 votes
1 answer
2k views

Move a file without releasing lock

I am using Java NIO in spring batch application. The application looks in a directory (e.g. /shared/inbox) where /shared is network shared disk among all instances of applications running on different ...
Overly Optimized's user avatar
4 votes
1 answer
2k views

How can I change layout params while program is running

I have an ImageView sitting on a FrameLayout. I want to be able to move this imageView by setting a margin: LayoutParams lp = new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); lp.setMargins(...
Klimov Ilya's user avatar
3 votes
1 answer
440 views

Use of a moved from object

I want to call a function that constructs a stringstream object and if some condition is met, invalidate the stringstream. When I try this, I get a warning from using a moved from object. How can I ...
cainsr2's user avatar
  • 55
3 votes
1 answer
242 views

Boost python not seeing memory is owned by smart pointer

I am getting a seg fault trigger when the destructor below destroys it's vector elements. Originally it was a vector<Parent> but I changed this to vector<unique_ptr<Parent>> and ...
user997112's user avatar
  • 29.9k
3 votes
0 answers
691 views

Renaming a remote file using Net::SFTP::Foreign

I am using a below script for renaming a file on a remote host. I want to connect to a remote machine and then rename a file on the remote server. #!/u01/app/perl-5.28/bin/perl use strict; use Net::...
user1939168's user avatar
3 votes
2 answers
3k views

Move and copy text file in bash script

I referred to all the previous responses to this question from stackoverflow and tried out the following. But unfortunately, I am still encountering an issue. I have a text file named Rels_obs inside ...
Nayantara Jeyaraj's user avatar
3 votes
0 answers
525 views

Function argument as __builtin_constant_p?

Is it possible to have a function argument which is __builtin_constant_p? This macro works fine: #define FOO(a) {\ static_assert(__builtin_constant_p(a));\ } void bar() { FOO("abc"); } I ...
Jan Rüegg's user avatar
  • 9,817
3 votes
0 answers
108 views

C++ swapping std::basic_string with differing char_traits

Searched around for this, but the best result has only been to copy the string. Given this simple snippet: struct custom_string_traits: std::char_traits<char> { static bool eq(char c, char ...
TekuConcept's user avatar
  • 1,274
3 votes
1 answer
389 views

Google Drive API v3 javascript: moving files

I'm trying to move files with javascript in my Google Drive but I am not success. The code use 2 request for Get current parents of the file Remove previous parents and add the new one. newParentId ...
Pierpaolo Fernandez's user avatar
3 votes
1 answer
888 views

copy constructor on base class

List C.67 in the cpp core guideline says: A base class should suppress copying, and provide a virtual clone instead if "copying" is desired. If the copy constructor is defined as deleted in the ...
pchrys's user avatar
  • 189
3 votes
1 answer
1k views

how to copy my python virtualenv to another machine

I made my virtualenv on my ubuntu pc machine. and I developed my project on there. But I need to move my environment as it is include all packages. because the target machine can't connect outside by ...
ChangSun An's user avatar
3 votes
0 answers
485 views

Shortest path between nodes in netlogo using nw extension

I want to find the shortest path between two nodes - slocation and new-location - in a network of links I have several slocation and new-location. One slocation for each citizen with some age, sex, ...
Sss's user avatar
  • 427
3 votes
0 answers
88 views

Is it possible to call a member function that moves the object?

Suppose I have a class Foo which has a member variable of type std::vector<Bar>: class Foo; class Bar { public: int x; Foo* parent; void trigger(size_t i); }; class Foo { public: ...
nitronoid's user avatar
  • 1,499
3 votes
0 answers
1k views

Moving SCNNode on horizontal plane in ARKit

In ARKit, when a horizontal plane is detected. I add a plane like structure (SCNNode) with very small height so it looks like floor. Then i add more objects like cube etc. on tap of that plane. Now i ...
AKumar's user avatar
  • 401
3 votes
0 answers
446 views

How to throw an exception with a std::unique_ptr member variable

I want to do something like this: class Exception : public std::exception { std::unique_ptr<Data> data; public: Exception(std::unique_ptr<Data> d) : data(std::move(d)) {} std::...
Matt's user avatar
  • 21.5k
3 votes
1 answer
7k views

How can I use "System.Net.ServicePointManager" in .net core?

I have a trouble: ASP.NET 4.0 has the class System.Net.ServicePointManager, but I can't find it in .NET core. How to find it?
Kan Hing's user avatar
3 votes
1 answer
3k views

Selenium: move mouse to element doesn't work

I am trying to take the time in the popup which only appears when I move mouse cursor on it. Then move mouse to another point. I tried with firefox and phantomjs on osx and ubuntu. Phantomjs never ...
hzleonardo's user avatar
3 votes
1 answer
528 views

move To behaviour not working: Game Salad

I am trying to move an object to 100px left in GameSalad. For that I am doing as below: Behaviour : Move To Position X : sprite.x = sprite.x - 100 Position Y : sprite.y Relative to : scene Speed ...
Krishna Raj Salim's user avatar
3 votes
1 answer
460 views

django-mptt: .move_to is not working in test runner

the .move_to() method is not working for me. I've looked at other posts an people recommend saving the instance, as well as re-loading the node instances. But none of these solutions work in this test ...
Andre's user avatar
  • 1,302
2 votes
0 answers
116 views

How to move an object with a bound function as member

Let say I am binding a function in a class to this: class SubObject { public: SubObject(std::function<void()> handler) : handler(handler) { } private: std::function<void()> ...
Stefan's user avatar
  • 721
2 votes
1 answer
107 views

Moving the last element of a vector

What is the most efficient way to obtain the last (heavy) element from a vector and remove it, and make as few copies as possible? Is it template <typaname T> T moveLastElement (std::vector<T&...
prestokeys's user avatar
  • 4,825
2 votes
0 answers
316 views

Why vector.tcc implement _M_fill_insert by __uninitialized_move_a?

In gcc vector.tcc::_M_fill_insert function (line524), the implementation uses case 1: __uninitialized_move_a(line562) for case of uninitialized but existing memory; case 2: ...
user3059627's user avatar
2 votes
1 answer
104 views

VS Code: How to move terminal to the left after Feb update

I would like to move the terminal/debug/ports panel to the left of the editor, side-by-side with the explorer. Previously, I just right-click the terminal and there is an option to do so. After the ...
Ruochen Wang's user avatar
2 votes
0 answers
156 views

Directory.Move() throws IOException regardless of the FileShare options for internal files

I am trying to rename or move the folder with a file, which is located in this folder being opened for reading. This blocks the folder renames, even though the file is opened with FileShare.Delete, ...
Maks Fetovich's user avatar
2 votes
0 answers
113 views

How to rename and relocate the most recently downloaded file via python?

I'm just wondering how I can write a code that locates the most recently downloaded file - without me knowing the name of said file - and renames and relocates it to a specified directory via Python ...
YSWS's user avatar
  • 57
2 votes
0 answers
205 views

RVO or automatic move

Consider the following function. std::string foo() { const std::string s = "hello"; return s; } clang-tidy suggests to remove const qualifier as is prevents an automatic move. Is this ...
Anubis's user avatar
  • 7,245
2 votes
0 answers
492 views

move constructor and assignment operator for class with a reference member

I'm new to move semantics, and I've been reading several resources that explain the correct way of defining a move constructor and assignment operator. All introductory material seems to use a class ...
Jeremías Rodríguez's user avatar
2 votes
0 answers
155 views

How std::vector know whether it can utilize move semantics or not when it needs reallocation

I guess that std::vector uses allocator_traits::construct when it copy/moves the elements into the reallocated buffer. Then I think that it needs to evaluate whether the function throws or not, to ...
a.tana's user avatar
  • 51
2 votes
1 answer
356 views

C++ std::move() performance wise with lvalues

I've just finished learning about lvalues, rvalues, move constructor and move operator. I can see the added value of using move constructor with rvalues performance and usability wise. But i can't see ...
ColdHands's user avatar
2 votes
0 answers
1k views

Move list of messages (filtered message) in a folder to another folder

Is there a way to move filtered messages from one folder to another folder? I already checked these two docs https://learn.microsoft.com/en-us/graph/api/message-move?view=graph-rest-1.0&tabs=http ...
yopiangi's user avatar
2 votes
1 answer
1k views

Moving std::istream

I have a Scanner class to tokenize streams of characters coming from files, cin, etc. class Scanner { public: Scanner(std::istream&& c) : input{std::move(c)} {} private: std::istream ...
Touloudou's user avatar
  • 2,133
2 votes
0 answers
133 views

How to unite two vectors effectively by reference?

In case of two vectors, both containing already allocated data: Considering the vector only contains primitives, what is the most effective way to concatenate one after the other without copying ...
Dávid Tóth's user avatar
  • 3,014
2 votes
0 answers
105 views

How to use move semantics for std::vector member without breaking encapsulation?

Let's suppose that I have a class with a private std::vector member, and the class maintains some contract on the content of the vector, e.g., keeps elements sorted. #include <algorithm> #...
Alexander Belous's user avatar
2 votes
0 answers
339 views

Error in dimnames(slot(x, "coords") when running align_move in move package

I am trying to run an animation in Move and MoveVis 0.10.1 package and I keep getting the following error: Error in dimnames(slot(x, "coords")) <-`*vtmp*` : length of 'dimnames' [1] not equal to ...
Dominique Turney's user avatar
2 votes
1 answer
713 views

std::variant of template specializations converting move constructor

I am using a class that encapsulates an std::variant of template specializations, such as: template<typename Type> struct Generic_node {...}; struct Leaf_node : Generic_node<...> {...}; ...
Judge Pepe's user avatar
2 votes
0 answers
117 views

Make ball move away from ball on click

There are some questions similar to this one and I have read them all but what I need is of a very specific nature. Essentially I have a ball with a round area around it that can be clicked. When you ...
Ricardo Affonso's user avatar
2 votes
0 answers
748 views

Powershell move folders based on part of a name

I have bunch of folders named like that XXXXXXX_XXXXXXXX_XXXXXX_XXXX_XXXX and based on that I would like to create folders with the first part of the name (XXXXXXX) and put matching folders with the ...
LunaticRover's user avatar
2 votes
1 answer
797 views

Batch: Using lookup file to search directory tree and move files

My query resolves around a large directory of images, with a complex series of sub-directories, and needing to perform a lookup for a list of files, and moving said files. I have found a few possible ...
s.ferguson's user avatar
2 votes
0 answers
232 views

Python: Efficient way to move a huge list of data from one list to another

I'm using multiprocessing, and in a separate process (let's call it thread for clarity), I'm using PySerial to pull data from a device. In my program, I have a list that's shared with the main thread. ...
The Quantum Physicist's user avatar
2 votes
0 answers
118 views

C++ lambda - move object after captured in lambda

I have this code: template<class Value> inline void item_controller<Value>::middle_touch(item_value_view&) { detail_item_controller<Value> detail; detail.value(value_); ...
user3613019's user avatar
2 votes
0 answers
43 views

C++11 noexcept doesn't affect "copy/move" choice in VC. Is this a VC bug?

[Effective modern C++]says, vector::push_back will allocate new memory block when capacity is not enough,and then "copy or move" elements to the new block Whether to choose copy or move depends on a ...
Hind Forsum's user avatar
  • 10.1k

1
2 3 4 5
20