Optimize integer program in speed I want to optimize the following small integer program in speed. My g++ compiler version is 4.3.4 on 32 bit linux. Please suggest or comment the following ideas. Some ideas are: 1. use compile flag such as -O3 2. rewrite the bigger function with function object #include <algorithm> #include <cstdlib> // for ab... 17 Jun 2010 07:50
Review of a safer memory management approach for C++? Hello, I am interested in finding one or more individuals who are knowledgeable about memory management in C++ (and especially of the reference-counting approach taken by classes like boost::shared_ptr and boost::weak_ptr) to review an idea for a comprehensive approach to safer memory management in C++ that enca... 9 Jun 2010 00:59
Is it valid to assign a reference from a ternary expression (i.e. operator ?:) { question was about the validity of the code similar to class T {} objA, objB; T& objRef = (boolean expression) ? objA : objB; next time please do provide quoting yourself. thanks. -mod } Thank you both. I appear to have completely glossed right over 5.16.4: "If the second and third operands... 4 Jun 2010 16:58
Aggregate initializers of static objects Hello, lets start with the code. // code begin static int data[] = {1, 2, 3, std::accumulate(data, data+4, 0)}; // code end The question is, is this definition without undefined/unspecified behaviour? Paragraph 3.6.2 states that for static objects there are two phases of initialization - static and dyn... 6 Jun 2010 10:29
Is it valid to assign a reference from a ternary expression (i.e. operator ?:) On Jun 4, 3:54 am, JoeO <joseph.m.ole...(a)gmail.com> wrote: I've got old code which attempts to assign a reference to an object from the results of a ?: ternary expression. Is this valid? To illustrate class T {}; void Foo() { T objA; T objB; T& objRef = (boolean express... 4 Jun 2010 10:18
template class with template member function in cpp file Hi everyone, Just a stupid problem, since i need to separate codes in header and source files (for cross reference), I found it's really difficult to work with templates in separated source file. For example: // MyClass.h template <class T> struct MyClass{ Template <typename InputIterator> T getMyBa... 4 Jun 2010 16:58
Is it valid to assign a reference from a ternary expression (i.e. operator ?:) On Jun 3, 12:54 pm, JoeO <joseph.m.ole...(a)gmail.com> wrote: I've got old code which attempts to assign a reference to an object from the results of a ?: ternary expression. Is this valid? To illustrate class T {}; void Foo() { T objA; T objB; T& objRef = (boolean expres... 4 Jun 2010 01:36
Is it valid to assign a reference from a ternary expression (i.e. operator ?:) I've got old code which attempts to assign a reference to an object from the results of a ?: ternary expression. Is this valid? To illustrate class T {}; void Foo() { T objA; T objB; T& objRef = (boolean expression) ? objA : objB; (do something with 'objRef') } Of course 'objRef' ... 3 Jun 2010 15:38
Access method names for std::random The std::random replacement for std::tr1::random utilizes a couple of different naming conventions. Apparently this is based on whether the distribution has well-accepted names such as mean, sigma or lambda. The result is, however, non-uniform naming which means each developer may end up reimplementing an uniform-... 2 Jun 2010 15:21
accumulating number of chars in vector<string> Hi, I hope the subject wasn't too obfuscated, Let's say that I have a vector<string> and a function size_t foo(string inVal) { return someNumberRelatedToTheString; } I want to accumulate the return values of foo calls. currently I failed doing it in a one accumulate call so I broke it into transform... 3 Jun 2010 04:33 |