3 ms·
This would introduce another performance consideration though, wouldn't it? You may not be paying the cost for the explicit copy, but now you are paying the co
by pdovy 16y ago
This would introduce another performance consideration though, wouldn't it? You may not be paying the cost for the explicit copy, but now you are paying the cost of allocating space for a Foo on the heap instead of the stack.
It would depend on the situation, but this seems like it might just be wash at the end in terms of performance?
- 124816 16y agoThat weird new(T* )T(...) syntax is how you ask c++ to run the constructor of T on an existing T* . (In this case that T* would point to the stack.) Note that the memory at the T* shouldn't be a real T; or if it is, its destructor ought to be run first.