return value optimization vs. returning a boost::shared_ptr of container On Jun 18, 11:30 am, "Martin B." <0xCDCDC...(a)gmx.at> wrote: That's why I pointed out that return-by-value may be more expensive that other alternatives when doing an assignment instead of initialization. (I do think it does not really matter with C++0x move semantics, because this is also applied when assig... 18 Jun 2010 21:16
Array within class object how do I traverse? Hi I frequently find that that I move std::vector member or array members outside of a class object simply because of the difficulty of providing an interface to the member through the class interface. If it was a single object, it would not be a problem. I wish to traverse the said member using lower_bound() and ... 23 Jun 2010 09:29
A case where conventional wisdom may not apply Conventional wisdom says to get the code working and then profile it and then make those parts that are too slow faster. What if the original goal is to make the code in the ball park of as fast as possible? For example how fast is fast enough for a compiler? In the case of the time it takes for a compiler ... 13 Jul 2010 04:20
Ways to over-write freed stack memory? We're looking for places in our code where memory is mis-used. One tool we've used is a custom malloc library which writes DEADBEEF or whatever into newly allocated and freed memory. I'm wondering if there are similar things you can do with the stack. I'm envisioning something that whenever a function returns, ... 21 Jun 2010 01:29
template<class... Arg>; variadic "while" //variadic "for"// I do not know if anyone suggested this, but I think this would be a good special case for a C++ while loop; template<class... Arg> inline ReturnVal fun(Arg&&... arg){ while(arg...){//or for(;arg;)// //code.................// ... 17 Jun 2010 14:30
Help with Code Please Ok, so I've just recently started programming again with c++. I've been working on a simple text RPG and i need some help with my current project. And also, this is the first time ive posted on this forum so if i post my code wrong or something please tell me. #include<iostream> #include <stdlib.h> #include <tim... 18 Jun 2010 11:18
shared_ptr question Is a warning/error compiler message expected for the code snippet below? struct Student; int main() { struct Student *ps; shared_ptr<Student> sps(ps); return 0; } I expect front end to complain about Student not being defined and ps not being dynamically allocated, but it doesn't. Thanks in... 18 Jun 2010 11:18
return value optimization vs. returning a boost::shared_ptr of container Mathias Gaunard wrote: On 15 juin, 10:05, Peng Yu <pengyu...(a)gmail.com> wrote: If there is return value optimization (RVO), I think that I can return tr1::unordered_map as the compile can optimize away unnecessary coping in certain cases. But I think that there cases where RVO doesn't help. For e... 18 Jun 2010 11:18
return value optimization vs. returning a boost::shared_ptr of container On 15 juin, 10:05, Peng Yu <pengyu...(a)gmail.com> wrote: If there is return value optimization (RVO), I think that I can return tr1::unordered_map as the compile can optimize away unnecessary coping in certain cases. But I think that there cases where RVO doesn't help. For example, if tr1::unordered_map is... 18 Jun 2010 14:37
return value optimization vs. returning a boost::shared_ptr of container Goran wrote: On Jun 15, 11:05 am, Peng Yu <pengyu...(a)gmail.com> wrote: Hi, I heard that most (if not all) containers in C++ standards (including the upcoming one) and in boost.org do not follow copy on write semantics. (Please correct me if I'm wrong.) Therefore, if I need to construct so... 15 Jun 2010 15:22 |