c++

Boost asio io_service dispatch vs post

Can anyone tell me the difference between io_service dispatch and post? It was not clear to me what is more suitable for my problem. I need to invoke a handler inside another handler and I don't what invoker to use. Thanks. ...

Isn't a pointer just a reference when you don't dereference it?

Isn't a pointer just a reference when you don't de-reference it? #include "stdafx.h" #define BOOST_TEST_MODULE example #include <boost/test/included/unit_test.hpp> std::list<int>* user_defined_func( ) { std::cout << "BEGIN: user_defined_func" << std::endl; std::list<int>* l = new std::list<int>; l->push_back(8); l->pu...

Need a cache which is shared between C++, Java and .Net Applications

Is there a caching solution which works with C++, .Net and Java all accessing and populating same data in cache? (Data is composed of simple strings only) Longer version: I have 4 applications which work on different areas of a problem. Two of them are developed in C++, one is a java desktop application, and another is a C# application...

Two .c files have identical compilation settings - VC++ reports no error and doesn't compile one of them

I'm trying to compile a set of .c files from an open source project into a static library. I've created a VC++9 project file, set everything up as usual. I add two .c files into the project. They don't have any special compilation settings - all the settings are set at the project level and are set to default except that I turned off the...

long double to string

I'm developping in C++, using the Qt framework. I need to convert a long double value into a string (ideally a QString, but could be something else). So far, I always used QString::number() for numerical->string conversion, but there is no overloading for the long doubletype. Thanks ...

Why would someone use C instead of C++?

Possible Duplicate: Why artificially limit your code to C? I started off with learning C, but then jumped straight into C++ simply because it supports OO and was also required for subsequent work. However, some companies insist on employing people with particularly strong C experience - and I've noticed this applies especially...

How to get qmake to generate "project dependencies" in a Visual Studio .sln project

I have a qmake build of a few libraries and an app which depends on them. Using the subdirs template I'm able to get qmake to output a .sln file which works almost to my liking in VC2008. Though I've specified the dependencies between the targets in every way I've seen described, I end up with no "project dependencies" in the .sln file...

How to set up C++ Number Formatting to a certain precision?

Hi, I understand that you can use iomanip to set a precision flags for floats (e.g. have 2.0000 as opposed to 2.00). Is there a way possible to do this, for integers? I would like a hex number to display as 000e8a00 rather than just e8a00 or 00000000 rather than 0. Is this possible in C++, using the standard libraries? ...

VS2010 RC - only 100 std::map elements in debugger

Hi, I have a small problem during debugging my App in VS 2010 RC when I want to see all the elements of std::map container. When debugger reaches the breakpoint and I want to check the values of the map in element inspector (in 'Locals' windows and in pop-up windows after hovering the variable name with mouse as well) and I'm scrolling ...

How can I decrease complexity in library without increasing complexity elsewhere?

I am tasked to maintain and update a library which allows a computer to send commands at a hardware device and then receive its response. Currently the code is setup in such a way that every single possible command the device can receive is sent via its own function. Code repetition is everywhere; a DRY advocate's worst nightmare. Obvio...

How to introduce boost::shared_ptr into an existing (large) C++ codebase?

Hi, I am currently trying to fix a few weaknesses in our code base by introducing the use of smart pointers. The code base is very large, and interlinked like a spider who's had one to many coffee's. I was wondering if people had tried the before and what their approach was. My first step has been to typedef classes, as follows. #ifn...

How does symbol binding work for shared libraries in linux

When compiling a cpp program with g++ -O0 I noticed that my binary does not contain the symbol for the empty string (basic_string): _S_empty_rep_storage When I do compile this same program with -O2 I notice that the aforementioned symbol is indeed contained within the binary as follows (using nm on the bin): 00000000006029a0 V _ZNSs4_R...

Using unrar library - extracting files into a filestream buffer

What I need is to be able to extract the files in a .rar file into streams. I'm creating a test case to get a sense of how to use unrar source. I've been searching and tinkering for a while, but I can't figure out how to use the library. I'm surprised I can't even find documentation or a tutorial for it, considering how common .rar archi...

C++ string literal data type storage

void f() { char *c = "Hello World!" } Where is the string stored? What's the property of it? I just know it is a constant, what else? Can I return it from inside of the function body? ...

How does the delete in C++ know how many memory locations to delete

how does the delete operator work? Is it better then free()?. Also if u do ptr=new char[10], then delete using delete ptr, how does the pointer know how many locations to delete. ...

passing more data to std:set Comparison class

I have an std::set with the Compare class which requires additional parameter to compare keys. This variable parameter is determined in run-time and I pack it inside the set's keys just to make it accessible to Compare. However, the parameter logically belongs to the set rather than the keys so this solution looks awkward and duplicates...

how to use dll?

hello, i have have a program/project in vs2008 that uses a third party static lib. Now, it has come to my attention that i need to offer some api's via a dll. Apparently a thrid party program will use my dll via the apis i will provide. Can anyone give me some direction as to what I need to do? would i need to just create a dll in vs...

Unicode - generally working with it in C++

Suppose we have an arbitrary string, s. s has the property of being from just about anywhere in the world. People from USA, Japan, Korea, Russia, China and Greece all write into s from time to time. Fortunately we don't have time travellers using Linear A, however. For the sake of discussion, let's presume we want to do string operati...

g++ fails mysteriously only if a .h is in a certain directory

I'm experiencing an extremely weird problem in a fresh OSX 10.4.11 + Xcode 2.5 installation. I've reduced it to a minimal test case. Here's test.cpp: #include "macros.h" int main (void) { return 1; } And here's macros.h: #ifndef __JUST_TESTING__ #define __JUST_TESTING__ template<typename T> void swap (T& pT1, T& pT2) { T pT...

I'm creating opensource GPL H264 encoding lib/app (based on x264) do I need to pay for the license?

I'm creating opensource GPL H264 encoding lib/app (based on x264) do I need to pay for the license? ...