c++

How to release pointer from boost::shared_ptr ?

Can boost::shared_ptr release the stored pointer without deleting it? I can see no release function exists in the documentation, also in the FAQ is explained why it does not provide release function, something like that the release can not be done on pointers that are not unique. My pointers are unique. How can I release my pointers ? O...

Is it possible to lock some data in CPU cache?

I have a problem.... I'm writing a data into array in the while-loop. And the point is that I'm doing it really frequently. It seems to be that this writing is now a bottle-neck in the code. So as i presume it's caused by the writing to memory. This array is not really large (smth like 300 elements). The question is it possible to do it ...

How to Convert unicode version of ReadDirectoryChangesW

I need to convert Unicode version of ReadDirectoryChangesW to support multibyte is that possible ...

Constructing a C++ object (the MFC CRecordset) thread-safely

We're trying to build a class that provides the MFC CRecordset (or, really, the CODBCRecordset class) thread safety. Everything actually seem to work out pretty well for the various functions like opening and moving through the recordset (we enclose these calls with critical sections), however, one problem remains, a problem that seems t...

How do I use C++ to acquire image from frame grabber?

Hello, I would like to know how is it possible to use a free C++ program to acquire image from a matrix vision frame grabber. Thanks. ...

Wildcard search inside a Boost.MultiIndex data structure?

I'm trying to optimize my application by reducing round-trips to my database. As part of that effort, I've been moving some of the tables into memory, storing them as Boost.MultiIndex containers. As a side-effect of this process, I've lost the ability to do wild-card matching on my strings. For example, when the table was stored in My...

VXL: Run-Time Check Failure #2

With the VXL library: I'm using vnl_conjugate_gradient with VC8 (visual studio 2005) and occasionally I see this error in debug mode: Run-Time Check Failure #2 - Stack around the variable 'z' was corrupted.** This is happening while leaving the function cg_ in the file cg.c This function is literally packed with "goto" btw, could tha...

C++ using list with count() function

Hi, I have a list L which needs to count how many 1s it has in it. list<int> L; L.push_back(14); L.push_back(5); L.push_back(22); L.push_back(1); L.push_back(1); L.push_back(-7); the function that i have been given is : assert ( count(...,...,...) == 2); i need to know what would replace the ...'s. i have tried L.begin(), L.end(...

Storing a list of classes and specialising a function by sub-classing in C++?

I'm trying to subclass a class with a specialisation of how I want a particular function to be performed. However, C++ implicitly converts my class to its base class when I store it in a list. Clearly the list could store any subclass of the class, so this is acceptable, but how would I go about storing the class so I can access this par...

What C++ libraries should I be looking for if I want to modify a sound file and save it back?

I am looking for some advices for sound-related libraries for C++. My requirements are as follow: load a sound file - this means I need to know what type of sound is being input and then deal with it. For instance, an MP3 file should be decoded first before being further processed. modifying sound - we should be able to play around wi...

Help combining two functions in C++

I need to combine these two functions. and need help in so: int Triangle(GzRender *render, int numParts, GzToken *nameList,GzPointer *valueList) { if (on_screen) { return Position(render, pos); } } int Position(GzRender *render, GzCoord vertexList[3]) { GzCoord *pv[3]; int i,j; ...

Fast C++ Delegates

I'm aware of the following approaches to C++ delegates: . Interfaces with pure virtual functions . Boost.Function . The Fastest Possible C++ Delegates . The Impossibly Fast C++ Delegates . Fast C++ Delegates . Fast C++ Delegate: Boost.Function 'drop-in' replacement and multicast Each have their pros and cons. Some are faster, some ar...

AIR(Flex) local socket connection

When connecting from a local AIR/Flex application to a local application (c++) using sockets do you still need a socket policy file? If you do, is there an easy way to load the policy file without sending the policy from the local application you are trying to connect to? side note: I am writing both applications. ...

How to write directly to linux framebuffer?

How to write directly to linux framebuffer? ...

generating a random number within range 0 to n where n can be > RAND_MAX

How can I generate a random number within range 0 to n where n can be > RAND_MAX in c,c++? Thanks. ...

Client is having trouble connecting to server using sockets?

My server is up and running (connecting through telnet worked so I know its functional) but my client cannot seem to establish a connection. I have a feeling it has something to do with the way I'm filling out the sockaddr_in serverAddr struct. Can anyone please help? Thank you. int clientSocket; char hostname[256]; struct sockaddr_i...

C++ writing a modify_if function

Hi, I have a hw question which confuses me on what i have to do. The question is below: The idea is to design a generic function called Modify_If that will take an input x (passed by reference), and two functors f1 and f2. The function Modify_If will use functor f1 to determine whether x obeys a certain condition. If it does, Modify_if...

Redirect cout to a file vs writing to a file directly in linux

Hello, For C++/linux programs, how does writing to cout (when cout has been redirected to a file during program launch) compare against writing to the target file directly? (via say fstream) Does the system do the appropriate magic at the start of the program to make these two cases exactly equivalent or is the later gonig to be better...

List Control SetFocus Redraw Error on a Tab Control

Environment: Visual Studio 2008, Visual Studio Feature Pack, MFC Dialog App, Windows XP, New Common Controls. I'm having a problem with a list control that happens to be on a tab control. To reproduce the problem simply create a dialog based app. Place a tab control on that dialog, then put a list control onto that tab control. You d...

A way to destroy "thread" class

Here is a skeleton of my thread class: class MyThread { public: virutal ~MyThread(); // will start thread with svc() as thread entry point void start() = 0; // derive class will specialize what the thread should do virtual void svc() = 0; }; Somewhere in code I create an instance of MyThread an...