I am trying to come up with the best data structure for use in a high throughput C++ server. The data structure will be used to store anything from a few to several million objects, and no sorting is required (though a unique sort key can be provided very cheaply).
The requirements are that it can support efficient insert, ideally O(1),...
How can I use CRTP in C++ to avoid the overhead of virtual member functions?
...
If I want to build a native GUI application on Windows (C++), do I have to use MFC for the UI building framework, or are there other technologies I can use? I know it's a silly question, and the answer is probably, "use MFC or make API calls directly", but I'd like to hear some opinions.
...
ShellExecute() allows me to perform simple shell tasks, allowing the system to take care of opening or printing files. I want to take a similar approach to sending an email attachment programmatically.
I don't want to manipulate Outlook directly, since I don't want to assume which email client the user uses by default. I don't want to s...
I have a simple POJO web service published with Axis2 on Tomcat5.5
I try to consume it with ATL C++ client and it fails. Doing the same with a C# client works.
The problem is that ATL client sends soap body which looks like
<soap:Body>< xmlns="http://fa.test.com/xsd"></></soap:Body></soap:Envelope>
Notice the in...
I've long had a desire for an STLish container that I could place into a shared memory segment or a memory mapped file.
I've considered the use of a custom allocator and placement new to place a regular STL container into a shared memory segment. (like this ddj article). The problem is that STL containers will internally have pointers t...
The following code says that passing the map as const into the operator[] method discards qualifiers:
#include <iostream>
#include <map>
#include <string>
using namespace std;
class MapWrapper {
public:
const int &get_value(const int &key) const {
return _map[key];
}
private:
map<int, int> _map;
};
int main() {
...
I want to be able to zip files from my non-gui C/C++ application, on several versions of Windows, Linux/Unix, and MacOS.
The user will compile and run using this app using Eclipse + makefile or VisualStudio. I don't want the user to have to install something separately, or have my makefile install executables.
Prefer open-source. I'm a...
In C++, is (int) ch equivalent to int(ch).
If not, what's the difference?
...
Several times, while perusing the Boost library's documentation, I've run across return values that are marked "convertible to bool" (search that page for the phrase "convertible to bool", it's about a third of the way down). I once stumbled across an oblique reference to a paper explaining the reason for that, but have never been able t...
I'm looking for a clean C++ way to parse a string containing expressions wrapped in ${} and build a result string from the programmatically evaluated expressions.
Example: "Hi ${user} from ${host}" will be evaluated to "Hi foo from bar" if I implement the program to let "user" evaluate to "foo", etc.
The current approach I'm thinking ...
I'm reading The C++ Programming Language and in it Stroustrup states that the int value of a char can range from 0 to 255 or -127 to 127, depending on implementation. Is this correct? It seems like it should be from -128 to 127. If not, why are their only 255 possible values in the second implementation possibility, not 256.
...
In a product I work on, there is an iteration loop which can have anywhere between a few hundred to a few million iterations. Each iteration computes a set of statistic variables (double precision), and the number of variables can be up to 1000 (typically 15-50).
As part of the loop, we graph the change in the variables over the iterat...
Problem:
How can I tell if a selection of text in the CRichEditCtrl has multiple font sizes in it?
Goal:
I am sort of making my own RichEdit toolbar (bold, italic, font type, font size, etc). I want to emulate what MS Word does when a selection of text has more than a single font size spanning the selection.
Ex - You have a line of ...
AlertEvent::AlertEvent(const std::string& text) :
IMEvent(kIMEventAlert, alertText.c_str()),
alertText(text)
{
//inspection at time of crash shows alertText is a valid string
}
IMEvent::IMEvent(long eventID, const char* details)
{
//during construction, details==0xcccccccc
}
on a related note, the monospace font looks...
In the following code I loop through a map and test if an element needs to be erased. Is it safe to erase the element and keep iterating or do I need to collect the keys in another container and do a second loop to call the erase()?
map<string, SerialdMsg::SerialFunction_t>::iterator pm_it;
for (pm_it = port_map.begin(); pm_it != port_...
I have some old C code that I would like to combine with some C++ code.
The C code used to have has the following includes:
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "mysql.h"
Now I'm trying to make it use C++ with iostream like this:
#include <windows.h>
#include <stdio.h>
#include <string>
#include <iost...
I've been investigating the effort needed in getting menu items displayed in bold face - without having to draw the menu myself - and discovered MFS_DEFAULT menu item state after some googling. The MSDN documentation mentions
MFS_DEFAULT
Specifies that the menu
item is the default. A menu can
contain only one default menu item,...
I am calling an unmanaged C++ dll that expects a char* as one of its parameters and I want to push a byte[] into it. The project is written in VB.NET.
What type of marshalling will work for this?
...
I have a big lump of binary data in a char[] array which I need to interpret as an array of packed 6-bit values.
I could sit down and write some code to do this but I'm thinking there has to be a good extant class or function somebody has written already.
What I need is something like:
int get_bits(char* data, unsigned bitOffset, unsi...