c++

What are the Complexity guarantees of the standard containers?

Apparently ;-) the standard containers provide some form of guarantees. What type of guarantees and what exactly are the differences between the different types of container? Working from the SGI Page I have come up with this: Container Types: ================ Container: Forward Container Reverse Container Rando...

Texture Sampling in Open GL

i need to get the color at a particular coordinate from a texture. There are 2 ways i can do this, by getting and looking at the raw png data, or by sampling my generated opengl texture. Is it possible to sample an opengl texture to get the color (RGBA) at a given UV or XY coord? If so, how? ...

Your preferred C/C++ header policy for big projects?

When working on a big C/C++ project, do you have some specific rules regarding the #include within source or header files? For instance, we can imagine to follow one of these two excessive rules: #include are forbidden in .h files; it is up to each .c file to include all the headers it needs Each .h file should include all its dependa...

Incorrect function addresses in Visual Studio MAP-file

Hi, the function addresses (Rva+Base) in my MAP-file from visual studio doesn't match the one I see in the debugger (or when I manually inspect my stack frame). What could be causing this? /A.B. ...

Is there a way to simulate the C++ 'friend' concept in Java?

I would like to be able to write a Java class in one package which can access non-public methods of a class in another package without having to make it a subclass of the other class. Is this possible? ...

Manual for Cross-Compile a c++ application from linux to windows?

Just that. I would like some information (links, reference, examples...) to guide me to do that. I don't even know if it's possible. My objective is to compile a program in Linux and get a .exe file that I can run under windows. ...

Is it possible to enumerate the wxFrame children in wxWidgets?

I'm using the wxGlade designer to generate the GUI for a small application. It generates a class, inherited from wxFrame, which is the main application window. In order to facilitate the maintenance, I'd like to avoid writing additional code in this generated class. But all the widgets created with the wxGlade are actually created in th...

Determine highest .NET Framework version

I need to determine the highest .NET framework version installed on a desktop machine from C\C++ code. Looks like I can iterate the folders under %systemroot%\Microsoft.NET\Framework, but that seems kind of error prone. Is there a better way? Perhaps a registry key I can inspect? Thanks. ...

Position in Vector using STL

Hi, im trying to locate the position of the minimum value in a vector, using STL find algorithm (and the min_element algorithm), but instead of returning the postion, its just giving me the value. E.g, if the minimum value is it, is position will be returned as 8 etc. What am I doing wrong here? int value=*min_element(v2.begin(),v2.end(...

Is object code generated for unused template class methods?

I have a C++ template class that gets instantiated with 3 different type parameters. There's a method that the class needs to have for only one of those types and that isn't ever called with the two other types. Will object code for that method be generated thrice (for all types for which the template is instantiated), or is object code...

How do you catch a managed exception (from a delegate) in unmanaged C++

I have unmanaged C++ calling a managed delegate via the function pointer provided by Marshal::GetFunctionPointerForDelegate. This delegate has the potential to throw an exception. I need to be able to properly handle this exception in my unmanaged C++ to ensure things like pointer cleanup, and potentially rethrow the exception up into ...

Maintaining an index of a filesystem

I need to record in some kind of file, the specific time at which blocks are written to in a filesystem, over a number of physical disks (RAID). I intend to do this by periodically by interrogating the writing device to find out which block it is writing to at that specific time. At some later date it will be necessary to locate and r...

Any way to determine speed of a removable drive in windows?

Is there any way to determine a removable drive speed in Windows without actually reading in a file. And if I do have to read in a file, how much needs to be read to get a semi accurate speed (e.g. determine whether a device is USB2 or USB1)? EDIT: Just to clarify, USB2 and USB1 were an example. These could be Compact Flash, could be ...

Comparison Functor Types vs. operator<

In the Google C++ Style Guide, the section on Operator Overloading recommends against overloading any operators ("except in rare, special circumstances"). Specifically, it recommends: In particular, do not overload operator== or operator< just so that your class can be used as a key in an STL container; instead, you should cr...

C / C++ compiler warnings: do you clean up all your code to remove them or leave them in?

I've worked on many projects where I've been given code by others to update. More often than not I compile it and get about 1,000+ compiler warnings. When I see compiler warnings they make me feel dirty, so my first task is to clean up the code and remove them all. Typically I find about a dozen problems like uninitialized variables such...

Forward Referencing or Declaration in C++

How do I do forward referencing / declaration in C++ to avoid circular header file references? I have the #ifndef guard in the header file, yet memory tells me I need this forward referencing thing - which i've used before >< but can't remember how. ...

How do I set a data breakpoint in Visual Studio 2005 on the address of a dereferenced pointer?

I wonder if there's a way to do the following: I have a structure containing a member which is a pointer to a block of memory allocated by the kernel when I pass the structure to an API function (the structure is a WAVEHDR, the member is the reserved field.) I can set a data breakpoint on the value of the reserved member - that in itsel...

Serialization of objects: no thread state can be involved, right?

I am looking hard at the basic principles of storing the state of an executing program to disk, and bringing it back in again. In the current design that we have, each object (which is a C-level thingy with function pointer lists, kind of low-level home-made object-orientation -- and there are very good reasons for doing it this way) wi...

Converting registry access to db calls from MFC Feature Pack

We may start converting an old VS2003 MFC project to use the fancy new features provided by the MFC Feature Pack and VS2008. Several of the new UI controls would be very nice except for one thing - they automatically save their information to the registry. I don't have a problem with the registry, but for the multiple environments the us...

What is the best HTML Rendering Engine to embed in an application?

At the moment, our application uses the Trident Win32 component, but we want to move away from that for a few reasons, chief among them being our desire to go cross-platform. We're looking at WebKit and Gecko, but I'd love to get some feedback before I make a decision. Here are some of the most important requirements: It should be rel...