c++

std::list< std::unique_ptr<T> >: passing it around

Say I have a std::list of class T's: std::list<T> l; When passing it into functions, I would use a reference: someFunction( std::list<T> &l ) What is the best way to pass around (the elements) of a std::list of unique_ptrs? std::list< std::unique_ptr<T> > l; Like this: someFunction( std::unique_ptr<T> ptr ) Or this: someFun...

gprof on snow leopard problem

Problem lies in the fact that gmon.out file doesnt show correct data. All times are 0, and nothing is measured. gmon.out file is normally generated. I am using eclipse ide for c++, and linking, compiling and running programs as normal. Any help? ...

Android-ndk with eclipse: How to force reinstallation of apk.

Hi, I'm developing a library in c++ using the android NDK. Actually i created my project in android with both java and c++ sources. I can compile and run my project and all works fine. Now i would like to force eclipse to reinstall the apk on the phone even if the java code is unchanged but something changed on the c++ side. Infact if ...

Implementing FIX Protocol-based orders with support for Stop Loss and Take Profit

Dear All, I spent a substantial amount of time looking for examples or descriptions of how to implement order execution methodology that will support stop losses and take profits through FIX Protocol. I assume that I will have to generate three orders, the main one, the SL one and the TP one. I also assume that I will have to issue th...

C++: insert char to a string

Hello, so I am trying to insert the character, which i got from a string, to another string. Here I my actions: 1. I want to use simple: someString.insert(somePosition, myChar); 2. I got an error, because insert requires(in my case) char* or string 3. I am converting char to char* via stringstream: stringstream conversion; char* myC...

Is any book out there on programming FFMPEG encoding libs in c\c++?

Is there any book on programming FFMPEG encoding libs in c\c++? I found one http://dranger.com/ffmpeg/ ...

try to throw ratio in C++

This question got me thinking about the ratio between the number of exception throw sites and the number of try blocks in my own code. A swift grep on a couple of non-library projects indicated it is something like 150 throws to 1 try. This kind of surprised me - I was expecting something like 50 to 1 - and I wondered if others would lik...

c++ testing code

here is code which print "c++" in binary form and at the same time measure time #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main(){ unsigned int t = clock(); string c = "c++"; int t=0; for (int i=0;i<c.length();i++){ t = (int) c[i]; while (t!=0){ ...

Oldtimers: What was the emacs-like editor that came with MS C 5.0 (for DOS) in the late 1980s?

I bought MS C 5.0 after first getting QuickC 1.0 (I think because there was some limitation with QuickC that the full-blown C 5.0 didn't have, but I can't recall the details now). This was the summer of 1988 I believe. Anyway, there was an editor buried somewhere on the discs which wasn't the default editor. I can't remember the name of ...

How to structure this tree of nodes?

I'm writing a program in C++ that uses genetic techniques to optimize an expression tree. I'm trying to write a class Tree which has as a data member Node root. The node constructor generates a random tree of nodes with +,-,*,/ as nodes and the integers as leaves. I've been working on this awhile, and I'm not yet clear on the best str...

Randomly endless thread and various bugs, while parallel line-by-line reading/writing

Hi, I want to implement a parallel reading-processing-writing line by line based on boost::thread, but the current version has indefinite behaviour : the following test reads a CSV file by filling the read (concurrent) queue, which is simply transferred into the writing queue to be written in an output file (no processing for now). Pro...

Post-Initialize stringstream inside map?

How can I post-initialize an stringstream inside a map? Is it even possible or do I have to create a stringstream*? std::map<std::string, std::stringstream> mapTopics; if(mapTopics.end() == mapTopics.find(Topic)) { mapTopics[Topic] = std::stringstream(""); // Post Initialize <--- } std::map<std::string, std::stringstream>::iterat...

How to instruct GCC to stop after 5 errors?

Is it possible to instruct GNU c++ compiler to stop after 5 errors found? Can't find this in documentation. Thanks in advance. ...

GetObject - GetObjectA linker error

Hi, In my project I have a function named GetObject that is wrapped in one of my classes in my static library. When I call the function in another project that is using my library, I got this error: Error 1 error LNK2019: unresolved external symbol "public: class hamur::HamurObject * __thiscall hamur::HamurWorld::GetObjectA(class s...

C++ get array key in constructor of array of a custom class/struct?

If I have a simple class like this: class MyClass { MyClass(){} ~MyClass(){} public: int myArrayKeyValue; }; And later, I create an array of these classes: MyClass testing[10]; How, in the constructor, would I access the array key so I can set the myArrayKeyValue appropriately for each element of the array? So that I...

std::vector is very slow?

Here is what I'm doing. I have a class which I instance and it has a std::vector. when I first instance the class this std::vector is empty. The way I use it is I exponentially add to it and clear. Ex: Add a number, clear the vector: Add 2 numbers, clear the vector: Add 3 numbers, clear the vector, Add 4 numbers, clear the vector...

Is there anything wrong with using C++ vectors in structures?

Ok, I'm coming from vb.net to c++. Im trying to use vectors in a structure, but the compiler yells at at me for it. What is wrong with the current statement? #include <vector> struct FactorSet { vector<long long> UpperFactor(0); vector<long long> LowerFactor(0); }; Output error (Visual Studio 2008): Error 1 error C2059: syntax e...

C++ difference between reference, objects and pointers

This is a question from an exam in an advanced course in OOP, taught in C++ (in TAU university, this semester): Q: What is the difference between a C++ pointer and a reference? A. A reference is the entire object while a pointer is only the address of it. B. The same meaning, and difference is only in syntax and usage. C. The sy...

Returning a reference to object

How should i return a reference to object without getting a warning for example: std::string& GetString() { std::string str = "Abcdefghijklmnopqrstuvwxyz"; return str; } int main() { std::string str = GetString(); } This results a warning on compliation. ...

Std::vector fill time goes from 0ms to 16ms after a certain threshold?

Here is what I'm doing. My application takes points from the user while dragging and in real time displays a filled polygon. It basically adds the mouse position on MouseMove. This point is a USERPOINT and has bezier handles because eventually I will do bezier and this is why I must transfer them into a vector. So basically MousePos ->...