c++

Please explain two lines to me

typedef vector<double>::size_type vec_sz; vec_sz size = homework.size(); ...

Force compiler to not optimize side-effect-less statements

I was reading some old game programming books and as some of you might know, back in that day it was usually faster to do bit hacks than do things the standard way. (Converting float to int, mask sign bit, convert back for absolute value, instead of just calling fabs(), for example) Nowadays is almost always better to just use the stand...

vector -> Usage of member functions begin() and end() vs the operator[]

While using the vector why do we sometime use the operator[] like homework[mid] but other times use homework.begin(). Also, homework.end() not homework[end], but that's like begin. Is it just accessing the elements differently? It's more confusing this way, don't you agree? ...

Is there a boost smart pointer class that can be configured not to delete at destruction?

I have a list of smart pointers. I want some of these smart pointers to act as regular pointers, meaning they are simply a reference to an instance and are not involved in its deallocation. They might for example point to instances allocated on the stack. The other smart pointers in the list should act as regular boost::shared_ptr. He...

Any reason to overload global new and delete?

Unless you're programming parts of an OS or an embedded system are there any reasons to do so? I can imagine that for some particular classes that are created and destroyed frequently overloading memory management functions or introducing a pool of objects might lower the overhead, but doing these things globally?? Addition I've just fo...

Searching text with 'Match case' and 'Match whole word' in file in C++ or Java

Hi. I need a solution in C++ or Java. Are there standard functions? ...

which opensouce image library supports most file format can be used in commercial application

which opensouce image library supports most file format can be used in commercial application? ...

doxygen: how do I document \enum values out-of-line?

To be precise: I know how to dox enums at the point of declaration, I want to dox them out-of-line instead. I want to keep the header file free of doxygen comments; they're all in the .cpp file. This is not a problem for functions, classes, typedefs and so on. I can also document the enum itself like this: /*! \enum MyClass::MyEnum ...

notify an object when a thread starts

i have an object A which should be notified (A::Notify() method) when some thread starts or dies. Lets say this thread dynamically loads some DLL file of mine (i can write it). I believe i should write the dllMain function of this DLL, however i'm not sure how to get a reference to the A object from this function so i can run it's Notify...

C++ Boost io streams, error handling

Is it possible to make a custom stream work like the stanadrd ones in regard for errors? That is by default use the good/fail/bad/eof bits rather than exceptions? The boost docs only mention throwing an std::failure for stream errors and letting other error propagate (eg a badalloc from trying to allocate a buffer), however the boost co...

What is a "nearly-empty" class?

...

How to programmatically get the resolution of a window and that of the system in Linux?

I'm trying to get the resolution of the screen as well as the resolution of a specific window (in which a program is running) on Linux system. I don't need to modify the resolution, I only need the current values. As far as I know, we can call some system functions to do so on Windows, how can we do that on Linux, preferably using C/C++ ...

Memory Management on Objects in a C++ Collection

I have a map that relates integers to vectors (of objects). These vectors represent a set of tasks to perform. In order to reduce the amount of copying going on while using this map and vector I've set them up to make use of pointers. std::map<int, std::vector<MyObject *> *> myMap; During initialization of the class that holds myMap...

How to detect that a given PE file (exe or dll) is 64 bit or 32 bit

I need to detect whether a given .dll or .exe file is 32 bit or 64 bit At the moment I have only one solution: read the PE Header from the specified file and take the 'Machine' field from there. ( Specification: Microsoft Portable Executable and Common Object File Format Specification (.docx file) at section "3.3. COFF File Header (Obj...

compiling c++ with gcc/g++ complier

hi im new to c++ and i want to compile my testprogram . i have now 3 files "main.cpp" "parse.cpp" "parse.h" how can i compile it with one command ? ...

Why does Qt include empty class definitions of existing classes in the header files?

I am reading through the examples on the Qt page and am wondering why they add references to already existing classes in their code example: #ifndef HTTPWINDOW_H #define HTTPWINDOW_H #include <QDialog> class QFile; class QHttp; class QHttpResponseHeader; class QLabel; class QLineEdit; class QProgressDialog; class QPushButton; class H...

Using Common Header Files in eVC++ 3

Hello, I'm learning C++ and i have the eVT(eMbedded Visual Tools) installed in my computer, because of the eVB 3(eMbedded Visual Basic) for my VB pocket programs, but i'm learning C++, then i want to use the eVC++ 3 for develop some command line aplications, then only to test i created an HelloWorld aplication, just for test, but when i...

Java solution for C++ style compiler directive

I have a Java array: String[] myArray = {"1", "2"}; Depending on a condition that is known at compile time I would like to assign different values: String[] myArray = {"A", "B", "C"}; In C++ I would use something like #ifdef ABC // ABC stuff here #else // 123 stuff here #endif but what to do in Java? ...

minimum double value in C/C++

Is there a standard and/or portable way to represent the smallest negative value (e.g. to use negative infinity) in a C(++) program? DBL_MIN in float.h is the smallest positive number. ...

Integrate Python And C++

Hello, I'm learning C++, because it's a very flexible language, but for internet things like Twitter, Facebook, Delicious and others, Python is so much more better, then i want to know if it's possible to integrate C++ and Python in a same project. Thanks! ...