c++

What is the lifetime and validity of C++ iterators ?

I'm planning to implement a list of Things in C++ where elements might be removed out of order. I don't expect that i'll need any kind of random access (i just need to sweep the list periodically), and the order of items isn't important either. So I thought of std::list<Thing*> with this->position = insert(lst.end(), thing) should do th...

run interpret c++?

Is there a way i can run c++ code as interpreted instead of compiled? so i can edit code and write functions on the fly? Related: Have you used any of the C++ interpreters (not compilers)? ...

Does const_cast ever cause actual code emission?

Is it true that const_cast is just a way to tell the compiler "stop moaning, treat this as a non-const pointer"? Are there any cases when const_cast itself is translated into actual machine code? ...

Programatically opening and closing a console

I'm writing a windowed program in C++, but I would like to have the option to pop up a console to output to from inside the program (such as various things that go on behind the scenes of my program, to see that everything is acting correctly). Is there an easy way to do this? EDIT: In this particular case I'm using sfml on windows, bu...

understanding WinDbg output

I have a Winform application (C#) which imports some functions from dll. Sometimes when running the application i get the following exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I catch it in AppDomain.CurrentDomain.UnhandledExc...

Spawned child exits with state = 127

Hi, I use posix_spawnp to execute different processes and I check the status (with waitpid) to make sure the child was created properly int iRet = posix_spawnp(&iPID, zPath, NULL, NULL, argv, environ); if (iRet != 0) { return false; } int iState; waitpid(static_cast<pid_t>(iPID), &iState, WNOHANG); cout << "Wait: PID "...

Internal typedefs in C++ - good style or bad style?

Something I have found myself doing often lately is declaring typedefs relevant to a particular class inside that class, i.e. class Lorem { typedef boost::shared_ptr<Lorem> ptr; typedef std::vector<Lorem::ptr> vector; // // ... // }; These types are then used elsewhere in the code: Lorem::vector lorems; Lorem::ptr lorem(...

c++ #define a macro with brackets?

Hi, Instead of doing the following everytime start(); // some code here stop(); I would like to define some sort of macro which makes it possible to write like: startstop() { //code here } Is it possible in C++? ...

Efficient way of storing Huffman tree

I am writing a Huffman encoding/decoding tool and am looking for an efficient way to store the Huffman tree that is created to store inside of the output file. Currently there are two different versions I am implementing. This one reads the entire file into memory character by character and builds a frequency table for the whole docum...

Problem nesting boost::lambda::bind-s

I have a generic function: void ImageAlbum::ExpressButtonPressed( boost::function< void ( thumb::PhotoPrintThumbnail*, thumb::PhotoPrintFormat, thumb::PhotoPrintQuantity ) > memberToCall ) { ... BOOST_FOREACH(thumb::PhotoPrintThumbnail *pThumbnail, m_thumbs.GetSelected()) { memberToCall( ...

Does someone have an optimized function to premultiply bitmap by alpha ?

GDIPlus blend functions use premultiplied rgb channel by alpha bitmaps for efficiency. However premultiplying by alpha is a very costly since you have to treat each pixel one by one. It seem that it would be a good candidate for SSE assembly. Is there someone here that would want to share its implementation? I know that this is hard wor...

Need user to input string /check string length (C++)

I'll need to accept a string of 5 numbers from the user (only 5). Should I use istringstream for the same ? Can't I get away with something like this ? int main() { char *InputMain; InputMain=(char *)malloc(5+1); cout << "Enter the number : " <<endl; cin.getline ( InputMain, 5, '\n' ); // Input goes int...

Using asynchronous RPC pipes without APC callback

Microsoft RPC has a mechanism called asynchronous pipes. The only sample for handling it I've seen so far (in MSDN) involves using APC (asynchronous procedure call) callbacks. Is there a way to implement client and server side pipe handling without APC - for example, with some wait functions? What are the key steps to doing this? ...

What does the suffix #DEN mean on the value of a variable

When debugging in VS2005 I have a float in the Locals window whose values is: 1.744e-039#DEN What does the #DEN signify/stand for? ...

What would you use to implement a fast and lightweight file server?

I need to have as part of a desktop application a file server which should respond as fast as possible to file transfer requests (from remote clients, usually located on the same LAN). There will be many file requests for small sized files. The server should be able to provide both upload and download services. I am not tight to any par...

Breaking in std::for_each loop.

While using std::for_each algorithm how do I break when a certain condition is satisfied? ...

Cannot edit labels in a CListCtrl

I'm building a project with MFC Feature Pack. Is this project I have a window which includes a CView, which includes a CListCtrl-derived object. The object includes the LVS_EDITLABELS flag. Somehow I cannot edit the CListCtrl icon labels by two-time clicking (not double-clicking) on the icon label. After I select the item with a single ...

Implementing a no-op std::ostream

Hi, I'm looking at making a logging class which has members like Info, Error etc that can configurably output to console, file, or to nowhere. For efficiency, I would like to avoid the overhead of formatting messages that are going to be thrown away (ie info messages when not running in a verbose mode). If I implement a custom std::st...

Get double value from .Net TextBox in C++

How can I get the double value from a textbox in .NET using C++. Do I have to get the text and do an atof() or is there an easier way? ...

ACE vs Boost vs Poco vs wxWidgets

I have a considerable amount of experience with ACE, Boost and wxWidgets. I have recently found the POCO libraries. Does anyone have any experience with them and how they compare to ACE, Boost and wxWidgets with regard to performance and reliability? I am particularly interested in replacing ACE with POCO. I have been unable to get A...