c++

Explain C++ SFINAE to a Python Guy

What is SFINAE in C++? Can you please explain it in words understandable to a Python programmer? Also, what concept in Python does SFINAE in C++ correspond to? ...

Can someone decipher whether timeGetTime() or QueryPerformanceCounter/QueryPerformanceFrequency has lower overhead or/and accuracy?

The idea is that an existing project uses timeGetTime() (for windows targets) quite frequently. milliseconds = timeGetTime(); Now, this could be replaced with double tmp = (double) lpPerformanceCount.QuadPart/ lpFrequency.QuadPart; milliseconds = rint(tmp * 1000); with lpPerformanceCount.QuadPart and lpFrequency.QuadPart being...

Is it possible to match templated base in template specializations?

I could of course use is_base if the base class where not a template. However, when it is, I just don't see any way to generically match any derived type. Here's a basic example of what I mean: #include <boost/mpl/bool.hpp> template < typename T > struct test_base { }; template < typename T > struct check : boost::mpl::false_ {}; t...

How to identify decent C++ developers in an informal gathering

I am going to an annual Free software/Open Source convention. This event is very community oriented and the hallway meetings are very informal. Since the company I currently work for is looking for C++ developers (in a Linux environment), I printed on a T-shirt the words "We are recruiting C++ developers" in large letters. Hopefully som...

Trouble restoring stdout after being redirected to a child process that exits

Currently I have a main process that creates an anonymous pipe and a child process and then uses the pipe to redirect console output to the child process. The pipe is created with CreatePipe, the read handle is passed as the StdIn handle for the new process using CreateProcess, and stdout of the main program is redirected to the write h...

using winhttp to connect to a multihomed host when the first ip is bad.

im trying to confirm that the feature described here: http://msdn.microsoft.com/en-us/library/aa384066(VS.85).aspx WINHTTP_OPTION_CONNECT_RETRIES Sets or retrieves an unsigned long integer value that contains the number of times WinHTTP attempts to connect to a host. Microsoft Windows HTTP Services (WinHTTP) only attempt...

C++ - What is the difference between ClassA *pClassA = new ClassA and ClassA *pclassA = new ClassA()

Possible Duplicate: Do the parentheses after the type name make a difference with new? Hello all, /* Sorry for my original post and I correct my question as follows */ Assume that ClassA is a well-defined C++ class and has a default constructor, etc. What is the difference between the following two cases: ClassA* pClassA = ...

Initializing static pointer in templated class.

This is difficult for me to formulate in a Google query (at least one that gives me what I'm looking for) so I've had some trouble finding an answer. I'm sure I'm not the first to ask though. Consider a class like so: template < class T > class MyClass { private: static T staticObject; static T * staticPointerObject; }; ... te...

Windows Mobile 6.5.3 preprocessor

Is there a preprocessor value I can use to detect when the program is being compiled for Windows Mobile 6.5.3? For example, I can use #if (_WIN32_WCE >= 0x501) to compile the code for Windows Mobile 5 and later, or #if _WIN32_WCE >= 0x502 to compile the code for Windows Mobile 6. There are some new API that exist in Windows Mobile 6.5....

c++ operator= method for const references

Hi, I am writing class with a const reference like this: class B; class foo { const B& b; foo(const B& newb): b(newb) { } void operator=(const foo & foo2) { // This does not work foo.b = foo2.b; } }; I am trying to define a working operator= Obviously = does not work since I am not allowd to change a const r...

How can I convert a binary file to another binary representation, like an image

I want to take a binary file (exe, msi, dll, whatever) and be able to actually "see" the binary code or whatever base I'd like (hexadecimal whatever). Figured the easiest way would be just to output the code into a txt so I can examine it. Whats the best and easiest way to do this? Basically I am looking to convert the binary code into ...

item size not adjusted after font change in CTreeCtrl

Hi, I change the font of tree items in CTreeCtrl with the following code: void CTreeCtrlEx::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTVCUSTOMDRAW pNMCD = reinterpret_cast<LPNMTVCUSTOMDRAW>(pNMHDR); *pResult = 0; switch(pNMCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: *pResult = CDRF_NOTIF...

On Linux, why does the destructor run twice on shared instance of global variable in C++?

On Linux I have some generated C++ code from a static library that defines a global variable. A single instance of this global variable is shared between two shared libraries that refer to its symbol. When the process shuts down and the static termination phase is run, I see that the destructor on this shared instance is run twice! Pr...

C++ & DirectX - setting shader

Hello! Does someone know a fast way to invoke shader processing via DirectX? Right now I'm setting shaders using D3DXCreateEffectFromFile calls, which create shaders in runtime (once per each shader) from *.fx files. Rendering part for every object (every patch in my case - see further) then means something like: // -----------------...

Distribute prizes for a tournament system

I'm looking for a way to distribute a number across x units. I don't even know how to put this words so I'll give an example: There's a tournament in which the total prize is $1000. I want that the top 20 winners/entrants will win something out of it.I need a mathematical algorithm/formula which will distibute it across those players, a...

CMake croscompile problem with CXX_FLAGS in linker

I have following toolchain for iPhone crosscompilation on mac os x: # Platform Info SET (CMAKE_SYSTEM_VERSION 1) SET (CMAKE_SYSTEM_PROCESSOR arm) # SDK Info SET (SDKVER "3.0") SET (DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer") SET (SDKROOT "${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk") SET (CMAKE_OSX_SYSROOT "${SDKROOT}") SET (...

Regex to parse C/C++ functions declarations

I need to parse and split C and C++ functions into the main components (return type, function name/class and method, parameters, etc). I'm working from either headers or a list where the signatures take the form: public: void __thiscall myClass::method(int, class myOtherClass * ) I have the following regex, which works for most fu...

Format(line wrapping) constructor initializer list in Eclipse CDT

I tried to find a solution for now ~30min and couldn't find any. I am trying to set up the code style in CDT so it gives me: MyClass::MyClass() : var1(1), var2(2), var3(3){ } instead of MyClass::MyClass() : var1(1), var2(2), var3(3){ } but I couldn't find an option to do so. The only 'initializer list' option I could f...

Putting class static members definition into cpp file -- technical limitation?

Hi, one of my "favorite" annoyance when coding in C++ is declaring some static variable in my class and then looking at compilation error about unresolved static variable (in earlier times, I was always scared as hell what does it mean). I mean classic example like: Test.h class Test { private: static int m_staticVar; int m_var; ...

Is it more efficient to use boost::asio::basic_stream_socket::async_read_some instead of boost::asio::async_read?

Is it better to use boost::asio::basic_stream_socket::async_read_some instead of boost::asio::async_read when it comes to high performance data throughput? ...