c++

Partial specialization of existing metafunction using mpl

Maybe I'm not all there today, but I'm wondering how to get this to work. I'd like to partially specialize range_mutable_iterator and range_const_iterator from the boost library but only for specific types that I'd rather avoid mentioning explicitly, instead only letting the partial specialization be chosen if the enable_if test criteria...

find c++ execution time

I am curious if there is a build-in function in C++ for measuring the execution time? I am using Windows at the moment. In Linux it's pretty easy... ...

How has C++ changed in the past decade?

I've barely/rarely used C++ in the past decade, and now it looks like I'll be doing something in it again. I'm looking forward to it, but have to wonder how it's changed since I last used it. Are there any good / brief web pages, blog posts, or even books on how C++ has changed in the past decade? Please note this question is regardin...

Windows C++ Should I use WinHttp library or XmlHttp from MSXML?

A rather simple question. Should I use the WinHttp library to make a web service request in my C++ programs or should I use the IXmlHttpRequest interface in the msxml library to send web service requests? Obviously the WinHttp library provides a lot more fine control compared to the IXmlHttpRequest library. But the XmlHttpRequest object ...

DuplicateHandle: need to OpenProcess, but the access is denied

Using windows hooks I send messages to my application, which is notified about Windows events by every application on the system. To execute marshal of the message parameters, I use shared memories. The external process calls DuplicateHandle, but for sharing the handle with my application instance, it shall call OpenProcess with PROCESS...

PONG Response to PING - Simple IRC Bot

I am writing a simple IRC Bot in C++. I am having issues, however, parsing "PING" properly. I cannot seem to extract the "PING" string from the output. I have a sample program setup (statically) with the same setup as my IRC bot and I can parse the string, but it does not seem to write properly when I actually apply the method to the bot...

Searching for a QObject

I'm working on a multi-threaded Qt application and would like to connect a signal in a thread with slot in another thread. My problem is that I only have the string used to set the QObject:objectName in the signaling thread that is defined in a project wide constants file. My overall goal is to avoid having to pass pointers to objects ...

Execution time limit for a Lua script called from the C API

luaL_loadfile(mState, path.c_str()); lua_pcall(mState, 0, 0, 0); Is there a way to put an execution time limit (say 10-20 seconds) for those two C++ statements, that load and then execute a lua file? Since the Lua file is untrusted I don't want a malicious user to hang the program indefinitely with an infinite loop in the Lua code. T...

shared_from_this called from constructor

I have to register an object in a container upon its creation. Without smart pointers I'd use something like this: a_class::a_class() { register_somewhere(this); } With smart pointers I should use shared_from_this but I can't use that in the constructor. Is there a clean way to solve this problem? What would you do in a similar s...

C++ binding question

Hello! Is there any way to make boost::bind work with std::fill? I tried the following, but it didn't work: boost::bind(std::fill, x.begin(), x.end(), 1); ...

Best way to parse a large floating point file stored in ascii?

What would be the fastest way to do it? I remember someone telling me using ifstream was bad because it worked on a small number of bytes, and it would be better to just read the file into memory first. Can anyone confirm this? Thanks Edit: I am running on windows, and the file format is for a point cloud that is stored in rows like ...

How do make C++ create an expression that uses compile-time checking for constants and asserts for variables?

Here’s an example setup… a macro or a template CHECKEXPR_RETURNVAL(EXPR,VAL) that checks that EXPR is TRUE while returning VAL. This is useful in a variety of places -- like in this highly simplified example: #define ISPOW2(VAL) ((0!=VAL)&&(0==(VAL&(VAL-1)))) #define _ALIGNPOW2(VAL,ALIGN) ((VAL+(ALIGN-1))&(~(ALIGN-1))) #defi...

binary file encryption problem

hello all. i'm having a problem while encrypting some data in the file. i'm using simple xor for that. lets say i have this struct: struct MyFile{ char fileName[128]; int account; float balance;}; saving this as a binary file is working properly but when i use xor to encrypt the filename in the struct and save the struct to hd then re...

std::sort on std::vector<std::string>

Hello, I have a std::vector<std::string> which would contain numbers and characters (single char). I would want to have numbers sorted first followed by the characters...so I have a jumbled up vector of strings as an input and after sort I want it like 1,2,3,5,7,9,10,A,B,C,D. But I guess sort also compares the sizes of the inputs, and h...

Stl methods with cmath functions

I was trying to write an STL method to take the log of a vector: for_each(vec.begin(),vec.end(),log); But I get no matching function for call to ‘for_each(__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, __gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, <unres...

Conversion from unsigned int to float

warning C4244: '=' : conversion from 'unsigned int' to 'float', possible loss of data Shouldn't a float be able to handle any value from an int? unsigned int: 0 to 4,294,967,295 float 3.4E +/- 38 (7 digits) Wiki: The advantage of floating-point representation over fixed-point (and integer) representation is that it ...

why didn't the positive terms get displayed in this asbolute program

Let's start with this demo #include <iostream> using namespace std; template <class T> void abs(T number) { if (number < 0) number = -number; cout << "The absolute value of the number is " << number << endl; return; } int main() { int num1 = 1; int num2 = 2; double num3 = -2.1333; float num4 = -4.23f; ...

how to show the device keyboard using C++ MFC for Windows CE device?

Hi, How to show the device keyboard using C++ MFC for Windows CE/Windows Mobile device to type in? thanks ...

Cleaning Up After OpenGL on iPhone

Right now, I'm playing with OpenGL ES on the iPhone using Oolong Engine. This might be a silly question, but how necessary is it to clean up after OpenGL when the app exits? My problem is that I have a static vector that manages loading models, and loosely ensures that models aren't loaded twice. Because of this, all the handles to the V...

Configuring a CMake C++/Java Project to work with Eclipse

Hello, I'm currently trying to set up a VTK project that has pre written Cmake makefiles to work with Eclipse. The code that I need to use is in both C++ and Java, but my main concern right now is actually to be able to translate the existing project into something that Eclipse can understand with all the dependencies etc. Please feel ...