copy-elision Questions
1
Solved
Do they work across different object files?
Do they work across different DLLs?
I know this depends on the compiler. I'm curious if there are any compilers and optimization settings that will make...
Thill asked 21/5, 2014 at 8:28
3
Solved
I'm trying to understand move semantics and copy/move elision.
I would like a class that wraps up some data. I would like to pass the data in in the constructor and I would like to own the data.
...
Couplet asked 15/3, 2014 at 15:23
2
I was playing around with C++ constructors. Here is my code:
#include <iostream>
using namespace std;
class ArrayWrapper
{
public:
// default constructor produces a moderately sized array
...
Invasion asked 30/1, 2014 at 21:35
6
This code:
#include <vector>
std::vector<float> getstdvec() {
std::vector<float> v(4);
v[0] = 1;
v[1] = 2;
v[2] = 3;
v[3] = 4;
return v;
}
int main() {
std::vector<...
Middle asked 18/10, 2013 at 16:3
1
Solved
I noticed something very strange with Visual Studio 2012: Defining a pair object like so:
auto objp = pair<int, LogMe>();
will not elide the copy/move of the pair in VC11, this call will ...
Officinal asked 9/10, 2013 at 21:17
1
Solved
I came upon https://web.archive.org/web/20120707045924/cpp-next.com/archive/2009/08/want-speed-pass-by-value/
Author's Advice:
Don’t copy your function arguments. Instead, pass them by value and
l...
Smallpox asked 16/9, 2013 at 9:50
1
Why RVO and NRVO optimizations are not made obligatory (when they are applicable) by the standard? e.g. there is a very common case when a function produces some object and returns it as the ...
Synecious asked 30/8, 2013 at 22:37
3
I have come across the situation where I really do need to execute non-trivial code in a copy-constructor/assignment-operator. The correctness of the algorithm depends on it.
While I could disabl...
Redskin asked 26/4, 2013 at 10:32
1
Solved
Possible Duplicate:
What happens if I return literal instead of declared std::string?
Consider the following code
string getName () {
return "meme";
}
string name = getName();
Th...
Athanasian asked 23/12, 2012 at 15:45
3
Solved
Normally, this would be optimised to not involve copying the large value (since a std::vector has move semantics enabled):
std::vector<int> makeABigThing(){
std::vector<int> large_thi...
Brisson asked 16/10, 2012 at 20:47
2
I push_back a temporary object into a vector like this,
vector<A> vec;
vec.push_back(A("abc"));
will the compiler apply copy-elision to construct the temporary A("abc") directly into the v...
Fonteyn asked 9/8, 2012 at 2:25
2
Solved
Possible Duplicate:
Why has the destructor been called only once?
Given the code below, I fail to understand the output in gcc. I expect two objects to be created and destroyed but in...
Eolic asked 17/1, 2012 at 6:24
3
Solved
Consider an exception class with a copy constructor with side-effects.
Can a compiler skip calling the copy constructor here:
try {
throw ugly_exception();
}
catch(ugly_exception) // ignoring th...
Venerate asked 13/9, 2011 at 12:2
5
Solved
I have a function which produces a type of expensive object (containing vectors and a maps of a non fixed size) so I really want to avoid invoking copy c'tors.
Until now I have just returned a std...
Groin asked 18/6, 2011 at 16:16
3
Solved
I'm still a rookie programmer, I know that premature optimization is bad, but I also know that copying huge stuff around is bad, as well.
I've read up on copy elision and it's synonyms but the exa...
Pangolin asked 26/5, 2011 at 13:22
2
Solved
I was reading Copy and Swap.
I tried reading some links on Copy Elision but could not figure out properly what it meant. Can somebody please explain what this optimization is, and especially what ...
Volley asked 27/1, 2010 at 0:37
3
I was reading Want Speed? Pass by Value on the C++ Next blog and created this program to get a feel for copy elision and move semantics in C++0x:
#include <vector>
#include <iostream>
...
Damage asked 7/11, 2009 at 13:19
© 2022 - 2024 — McMap. All rights reserved.