Skip to main content
0 votes
2 answers
234 views

What is the copy-and-swap idiom? lists copy-and-swap as a better alternative to self-assignment check, being simpler and providing stronger exception guarantees. Performance aside, are there any ...
Dominik Kaszewski's user avatar
3 votes
2 answers
219 views

I came across this table describing how the C++ compiler implicitly declares special member functions depending on which ones the user has explicitly declared: Source: Howard Hinnant - How I Declare ...
toliveira's user avatar
  • 1,857
2 votes
1 answer
188 views

I know this may be obvious to many, but please explain it to me: struct MyFoo { MyFoo(int& arg) : ref(arg) {} int& ref; MyFoo& operator= (MyFoo&& other) = default; ...
Zebrafish's user avatar
  • 16.3k
0 votes
1 answer
113 views

A relatively same question is asked before, but the code snippet is different, which I believe makes this question unique. Does the compiler generate the move operations in the following scenario? ...
Ali Sedighi's user avatar
0 votes
0 answers
86 views

I was trying to implement an emplace_back method for a statically-sized array (for fun). I came across the problem of whether I should use placement-new or move assignment for this emplace back method....
timmy george's user avatar
1 vote
0 answers
17 views

Somehow in one of or more of my loops are overrunning my buffer but I can't catch it. It's either that or somehow my capacity or size is at 0 when it shouldn't be but either way I can't find the issue ...
Shahab's user avatar
  • 11
0 votes
0 answers
114 views

In an answer to this question, under the label: "Why does that work?" , it was noted that: Now, if other is being initialized with an rvalue, it will be move-constructed. Perfect. In the ...
CS Student's user avatar
0 votes
1 answer
142 views

If there is function with the following signature: std::vector<std::vector<std::string>> some_func(); And its assigned to a variable of the same type: std::vector<std::vector<std::...
Tanvir's user avatar
  • 885
0 votes
0 answers
166 views

What is the automatically generated move assignment operator for a class Number that contains only one attribute of type std::shared_ptr<Vertex>? #include <iostream> #include <memory>...
GRamon's user avatar
  • 87
1 vote
1 answer
89 views

A simple question but I can not find the set of rules that proves that the behavior of the following code example is correct. It seems here that only strDerived is moved from b, but strBase is copied? ...
SoulfreezerXP's user avatar
1 vote
3 answers
245 views

I made some tests in GCC, Clang and MSVC and found out that emplace_back never calls an assignment operator on the contained class. It only calls the copy or move constructor when reallocation takes ...
really's user avatar
  • 123
4 votes
1 answer
1k views

I recently realized (pretty late in fact) that it's important to have move constructors marked as noexcept, so that std containers are allowed to avoid copying. What puzzles me is why if I do an erase(...
Costantino Grana's user avatar
1 vote
1 answer
2k views

I'm new to C++ and dont know why this is happening and how to fix it. Here's some snippets of the code: header file: class Dictionary{ private: string filename; const ...
Coder-Me's user avatar
0 votes
0 answers
201 views

The following code violates AUTOSAR C++ rule 6-2-1: Move and copy assignment operators shall either move or respectively copy base classes and data members of a class, without any side effects. Move ...
KplnMoon's user avatar
  • 159
6 votes
1 answer
672 views

For move construction: After the move, other is guaranteed to be empty(). 1 For move assignment, the oft-quoted: other is in a valid but unspecified state afterwards. 2 Why is the state of other ...
sleep's user avatar
  • 4,974

15 30 50 per page
1
2 3 4 5