c++

Calling 64-bit COM control from 32-bit app

We have a situation where one of our products is a 32-bit app, but needs to communicate with instruments via 64-bit COM control (which wraps a 64-bit device driver). For various reasons, we don't want to compile this app as a 64-bit app, but we DO want to run it on a 64-bit OS. Since the drivers and COM control must be 64-bit to work, w...

is it possible for set to have std::vector as underlying storage for storage of its elements?

For small collections std::vector is almost certainly the best container whatever the operations applied to it are. Is it possible to have std::vector as underlying storage for the elements set container instead red-black tree involving a lot of heap allocations (maybe boost has something?) or do I have to invent it myself? Plain std::v...

C++ Pointer Question

Hello, I apologize since this is rather a n00bish question, but I can't figure this one out. class View //simplified { public: ROILine* ROI() {return _roi;} //setter does some control stuff... private: ROILine *_roi; } class ROI : public eq::Object { public: //virtual ROI(ROI* copy) = 0; virtual ~ROI() {}; virtual ui...

C++: how to access a multidimensional array with pointers?

Given: (In C++) int main () { int* ptr; int ary [10][2]; ptr = ary; return 0; } How would I access ary[0][1] with ptr? ...

C++ boost variant question

Hello! I know that boost::variant uses boost::mpl stuff behind it and has a mpl-compatible typedef types. Let's say I have a simple typedef: typedef boost::variant<bool, int> Variant; Now I have another template function, let's say: template <typename T> T function() { // ... } I want this function to act differently for two ca...

boost condition. What am I doing wrong?

boost::condition_variable cond; boost::mutex mut; void Database::run() { boost::unique_lock<boost::mutex> lock(mut); while(true) { while(queries_queue.empty()) cond.wait(lock); mysqlpp::Query* q = queries_queue.front(); // <<< CRASHES HERE <<< q->execute(); queries_queue.pop_fron...

Are there standard restrictions on C++ features?

I am about to start a new realtime project. Now there is (again) the debate about c vs c++. Yes I read about Linus and all the other threads on SO. First I was tending more towards to use C but then I read an answer that C++ includes C. Then I read on the internet about "Embedded C++". According to this article EC++ is dead. But I thi...

Can I debug a core generated by a C++ binary without debug symbols using the same binary recompiled with debug symbols

I am trying to debug a core file generated by a C++ binary without debug symbols. In order to do effective debugging, I need the debug symbols, so I've recompiled the same code with -g option in order to generate debug symbols in the recompiled binary. Can I now debug the same core file generated by the first binary (without debug symb...

Floating point comparison - Result between different runs

I know that I can not compare two floating point or double numbers for absolute equality on C++/C. If for some reason, I write a if condition which uses the absolute equality, is it guaranteed that the if condition will return the same result on different runs of the program for same data? Or it is purely non-deterministic and the result...

How to convert a string of hex values to a string?

Say I have a string like: string hex = "48656c6c6f"; Where every two characters correspond to the hex representation of their ASCII, value, eg: 0x48 0x65 0x6c 0x6c 0x6f = "Hello" So how can I get "hello" from "48656c6c6f" without having to create a lookup ASCII table? atoi() obviously won't work here. ...

directx rotation c++

Okay this is a hard question. I'm creating a cube and a pyramid in one vertex array. My problem is to rotate only pyramid vertex not the cube vertex but I don't know any function that can rotate some vertex. If I try to rotate the vertex I'll get pyramid and cube rotated. ...

What is the correct type for this parameter?

This one is for all you ALSA guys. I need a sanity check here. I am using the the alsa-lib api to play sounds and the function that I am using to write the data to the driver is snd_pcm_sframes_t snd_pcm_writei (snd_pcm_t* pcm, const void* buffer, snd_pcm_uframes_t siz...

Using equal(),find() on a vector<complex <double> >

Hi all, This is a pretty straightforward thing, but I've been bashing my head trying to understand. I'm trying to compare the elements of a vector<complex <double> > vec with a complex <double> num to check if num already exists on vec. If it does, it is not added. I tried to use the equal() and algorithm, with no success. Does anybody ...

Passing a structure as a template-parameter - How can I fix this code?

Hi, I'm trying to compile the following code under VC2010. struct CircValRange { double a,b; // range: [a,b) }; template <struct CircValRange* Range> class CircVal { // todo }; const CircValRange SignedDegRange= {-180., 180.}; CircVal<SignedDegRange> x; I'm getting error C2970: 'CircVal' : template parameter 'Range' : 'S...

Where does the word "pragma" come from?

So I know what pragma is, and what it's used for, but what is the meaning of the word itself? I've used it many times in code, but I never really knew what the word actually means or stands for. ...

is there any difference between a public nested class and a regular class?

Hi lets say i Have: class A { public: class B { }; }; is there any difference between that public nested class an just a regular B class which is defined in its own cpp file, except for the face that A::B must be used in the first option? Thanks! ...

Relational container in c++ and polymorphism issues

Hi everyone. I would appreciate any help with this. I have a simple container template class Dataset. Also there is a specialization to allow a different implementation when a Dataset of Datasets is instantiated. Since a Dataset of Datasets would be a heterogeneous container, there is a base abstract class List wich must declare a com...

Enumerated type with arbitrary integer values

I want something like enum EnumType {val1 = -1, val2 = 1}; enum EnumType2 {val1 = 1, val2 = -1}; In particular, val1 and val2 depend on the enumerated type--EnumType or EnumType2. So I eventually want to be able to say something like EnumType x = val1; EnumType2 y = val1; and have x and y have different values. Is the foregoing p...

shared_ptr allocation optimization

Somewhere I saw a post about an optimized way of creating a boost shared_ptr so that it allocated the ptr plumbing and the pointee at the same time. I did a SO search but there are a lot of posts on shared_ptr and I could not find it. Can somebody smart please repost it edit: thanks for answer. extra credit question. Whats the correct (...

OpenGL ES render bitmap glyph as texture positioning issues

I'm just testing this stuff out, so I don't need an alternate approach (no GL extensions). Just hoping someone sees an obvious mistake in my usage of GLES. I want to take an bitmap of a glyph that is smaller than 32x32 (width and height are not necessarily powers of 2) and put it into a texture so I can render it. I've first created an ...