c++

What is the STL implementation with the lowest memory footprint?

I am working on a very large scale computing library that is using STL heavily. The library is being built using MSVC2003 and it is using its STL implementation. I am looking for an alternative STL implementation that would help the library lower its memory requirements and increase its performance. It is not possible to switch to a new...

Automatic casts

I am currently suffering a brain fart. I've done this before but I can't remember the exact syntax and I can't look at the code I wrote because I was working at another company at the time. I have this arrangement: class P { // stuff }; class PW : public P { // more stuff }; class PR : public P { // more stuff }; class C { public: ...

Get the IP Address of local computer

In C++, what's the easiest way to get the local computer's IP address and subnet mask? I want to be able to detect the local machine's IP address in my local network. In my particular case, I have a network with a subnet mask of 255.255.255.0 and my computer's IP address is 192.168.0.5.because I need to get these had two values programm...

Template Constraints C++

In C# we can define a generic type that imposes constraints on the types that can be used as the generic parameter. The following example illustrates the usage of generic constraints: interface IFoo { } class Foo<T> where T : IFoo { } class Bar : IFoo { } class Simpson { } class Program { static void Main(string[] args) { ...

Handling file paths cross platform

Do any C++ GNU standalone classes exist which handle paths cross platform? My applications build on Windows and LInux. Our configuration files refer to another file in a seperate directory. I'd like to be able to read the path for the other configuration file into a class which would work on both Linux or Windows. Which class would o...

What are some problems old C++ textbooks may have?

I've been trying to pick up C++ and I have an old textbook a professor gave me awhile ago. The book was published in 1998 and I've been reading through it. The first area that I ran into problems was in the graphic section. The textbook says to use the following library. #include <graphics.h> This didn't work with the system I'm on s...

How can I wrap BOOST in a separate namespace?

I'm looking to have two versions of BOOST compiled into a project at the same time. Ideally they should be usable along these lines: boost_1_36_0::boost::shared_ptr<SomeClass> someClass = new SomeClass(); boost_1_35_0::boost::regex expression("[0-9]", boost_1_35_0::boost::regex_constants::basic); ...

Reducing memory footprint of large unfamiliar codebase.

Suppose you have a fairly large (~2.2 MLOC), fairly old (started more than 10 years ago) Windows desktop application in C/C++. About 10% of modules are external and don't have sources, only debug symbols. How would you go about reducing application's memory footprint in half? At least, what would you do to find out where memory is consu...

Fast plane rotation algorithm?

I am working on an application that detects the most prominent rectangle in an image, then seeks to rotate it so that the bottom left of the rectangle rests at the origin, similar to how IUPR's OSCAR system works. However, once the most prominent rectangle is detected, I am unsure how to take into account the depth component or z-axis, ...

Generic cache of objects

Hi, Does anyone know any implementation of a templated cache of objects? You use a key to find object (the same as in std::map<>) You specify a maximum number of objects that can be in the cache at the same time There are facilities to create an object not found in the cache There are facilities to know when an object is discarded fr...

Do you use Qt and why do you use it?

Pros. and cons? how long do you use it? What about jambi? ...

How do I remove code duplication between similar const and non-const member functions?

Let's say I have the following class X where I want to return access to an internal member: class Z { // details }; class X { std::vector<Z> vecZ; public: Z& Z(size_t index) { // ... // massive amounts of code for // validating index Z& ret = vecZ[index]; // even more code for ...

fastest c++ file compression library available?

I have a need to find the best library to compress in memory data. I am currently using zlib but I am wondering if there is a better compression library; better in terms of performance and memory footprint. It should be able to handle multiple files in the same archive. I am looking for a C/C++ library. Performance is the key factor. ...

game programming

What libraries can i use for motion and blending in game programming in c++? I need libraries regarding sound, image, expansion algorithm like 2xsai and super eagle. I need libraries like fblend and also for motion . How to compile functions of fblend in devcpp? 2d gaming... and the library should be compatible with devcpp ...

C++ handling very large integers

Hey everyone, I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like P = C^d % n = 62^65 % 133 Now that is really the only calculations that ill be doing. I have tried using Matt McCutchen's BigInteger Library, but I am g...

Computing pseudo-inverse of a matrix in C++

I'm looking to compute the Moore-Penrose pseudo-inverse of a matrix in C++, can someone point me to a library implementation or a numerical recipe? Thanks! ...

How do I prevent a class from being allocated via the 'new' operator? (I'd like to ensure my RAII class is always allocated on the stack.)

I'd like to ensure my RAII class is always allocated on the stack. How do I prevent a class from being allocated via the 'new' operator? ...

Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new'?

Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap? ...

How to get the application executable name in Windows (C++ Win32 or C++/CLI)?

I need to change the functionality of an application based on the executable name. Nothing huge, just changing strings that are displayed and some internal identifiers. The application is written in a mixture of native and .Net C++ code. Two ways that I have looked at are to parse the GetCommandLine() function in Win32 and stuffing aro...

existance map in c++

I want something like an std::map, but I only want to see if the item exists or not, I don't actually need a key AND value. What should I use? ...