c++

c++ map erase()

I have a map in which my value is dynamically allocated. When I do erase() on an element, does this free the memory OR just removes the element from the map. I actually need to keep the memory as is. I just need to remove the element from the map since this dynamically allocated structure is used elsewhere in the code. ...

"Bitwise And" and Left-Padding in C++

I have a macro that looks something like this: Foo(x) ((x - '!') & 070) If I call the following code: Foo('1') => 16 However, if I call the following code: (('1' - '!') & 70) => 0 So my question is, what's going on here? Why does x & 070 compute to x but x & 70 compute to 0? My guess is that the extra 0 on the left is forcing 6...

iPhone Radio program with VU Meter

Fellow coders, I wrote an iPhone app that plays wma stream, using libmms and ffmpeg open source libraries. The app has already been approved by Apple and is available for download, free of charge. Now I'd like to have a VU meter on my app. I'm using the avTouch code sample, downloaded from Apple (https://developer.apple.com/iphone/lib...

Will GetPath() work for this?

I basically want to get the outline for a character. I was wondering how I could do this without drawing to the DC. Could I do something like this: (Psudocodeishly) BeginPath() TextOut("H") EndPath() GetPath() Will something like this work for GetPath? Will it return the glyph outline that I can then draw? Otherwise, how else could...

what could make 32 bit app incompatible with 64 bit linux OS?

It seems that most 32 bit applications will run on 64 bit linux assuming all the 32 bit libraries are present. But it seems to me there could be issues with architecture-dependent functions, and here I'm thinking of signals and setjmp/longjmp. I'm wondering if someone with greater experience could comment on what functions (if any) woul...

This is illegal right?

For a personal project I have been implementing my own libstdc++. Bit by bit, I've been making some nice progress. Usually, I will use examples from http://www.cplusplus.com/reference/ for some basic test cases to make sure that I have the obvious functionality working as expected. Today I ran into an issue with std::basic_string::repla...

Runtime check failure #2 C/C++

Hi all, I have encountered a problem in my program that has me somewhat stumped. I had a program that was working fine (it was working fine on VS 2010 this is not an I upgraded to .NET and this error started happening post) with a program that is mostly c and some c++ (my boss HATES object oriented since it usually involves making calls ...

segfault when using boost::signal with -D_GLIBCXX_DEBUG compiler flag

I'm building with g++, and yesterday a helpful person on SO told me to compile with the -D_GLIBCXX_DEBUG and -D_GLIBCXX_DEBUG_PEDANTIC flags. I did so, and I spent most of yesterday tweaking my code to conform to these flags. Now it's complaining about my use of boost::signal, and I'm not sure where the problem is. I have a class Yarl...

VS: Tooltip help for doxygen-style commented functions?

Hi all, I am using Visual Studio and an external library that is commented in doxygen-style. Is there any way to display doxygen documentation in the editor tooltip like DocXML? ...

Why should I avoid using malloc in c++?

Possible Duplicates: What is the difference between new/delete and malloc/free? In what cases do I use malloc vs new? Why should I avoid using malloc in c++? ...

How to get and pass Arabic characters in a non-unicode c++ environment

I'm currently working on a project that is written in C++ and uses True OLE DBGrids with a MS Access backend. This all works well until now we need to be able to convert our GUI to display Arabic characters. The DBGrids do not use Unicode so I need a way to display the characters from the database without using Unicode. Currently I ha...

serialize any data type as vector<uint8_t> - use reinterpret_cast?

I didnt find anything directly related in searching, so please forgive if this is a duplicate. What I am looking to do is serialize data across a network connection. My approach is to convert everything I need to transfer to a std::vector< uint8_t > and on the receiving side unpack the data into the appropriate variables. My approach lo...

Different ways of observing data changes

In my application I have many classes. Most of these classes store quite some data, and it is important that other modules in my application are also 'updated' if the content of one of the data classes changes. The typical way to do this is like this: void MyDataClass::setMember(double d) { m_member = d; notifyAllObservers(); } This...

Compare and swap library?

What is the best cross platform library to use for atomic compare and swap operations in c++? ...Or at least for amd64 on Linux and Windows? ...

Communication with running Windows service

Hi. How can I communicate with running Windows service without stopping it using native C++? I need to pass integers and strings to service and get integers and to get back integers and strings. Currently I do it through registry, but I would like use another, faster way. Thank you in advance. ...

managing wxAuiToolBars

I'm just loving these wx designs more and more... I have created this set of objects and such that are meant to represent tools that are accessable through the toolbar and through menus. These of course have to be managed independently and even if not, I need to be able to toggle things in response to events not associated with toolbar...

Why is it counting the last number twice?

My program is reading numbers from a file- and it reads the last number twice. What is wrong with my program and what can I do to fix it? int main() { ifstream inputFile; int number = 0; //the input for the numbers in the file double total = 0; //the total of the numbers double counter = 0;//number of numbers doubl...

A crash in injected / hooked target application.

I have injected my DLL into a target application where I've hooked few WINAPI-functions as well. One of them is DrawTextExW. I'm trying to replace all 'l' letters to '!' before it prints it out. My solution works fine for a few seconds, but then the target application crashes. I really don't understand why. Here's the function: Edit - ...

Which technology to chose for massive IO operation server

I need to build simple server that reads (potentially large) xml files processes them in memory(eg transform them to a different xml structure) writes them back to disk. Some important aspects of the program: speed ability to distribute the server. That means placing (what does that mean) several such servers and each server will ...

Best practice for a Qt application with multiple UIs in C++

The case is as follows: You have a main window (ui1) that is to contain two other UIs (ui2 and ui3). Neither ui2 nor ui3 care about any other uis. They only have slots to react to, and they might emit signals as well. See drawing below. +----------------------------+ | +------+ +------+ | | | | | | | | | ...