Couldn't creatively shorten the title :)
I have been using a variation of the below solution, however I always wondered if there is a better/cleaner way to implement it. I am looking for non-boost solution. We can, though, look at the implementation of boost and C++0x, as it will soon be relevant.
//Notice the use of template template...
I'm working on an MFC program that started way back in the VC6 days. Back then there was a class wizard that used a bunch of decorators and markup in comments to parse class files.
For example, it would insert afx_msg in front of message handlers that it maintained. It would mark a block of code with //{{AFX_MSG_MAP(TheApp) and /}}AFX_M...
if (x() > 10)
{
if (y > 5)
action1(p1, p2, p3, p4);
else
action2(p1, p2);
}
else
{
if (z > 2)
action1(p1, p2, p3, p4);
else
action2(p1, p2);
}
I real project on mine, action1 and action2 are actually 2-3 lines of code and those functions that are invoked take 6-8 parameters in total, so w...
I've been browsing revision 1.38.0 of the Boost libraries, in an attempt to decide if there are enough jewels there to justify negotiating my company's external software approval process. In the course of writing test programs and reading the documents, I've reached a couple conclusions
of course, not everything in Boost will ever be o...
Consider the following snippet:
struct Foo
{
static const T value = 123; //Where T is some POD-type
};
const T Foo::value; //Is this required?
In this case, does the standard require us to explicitly declare value in a translation unit? It seems I have conflicting information; boost and things like numeric_limits from the STL see...
Is there any compiler setting or other way to force an int to be initialized to 0?
...
I saw the following posted by one of the fellow stackoverflower and it sort of dumbfounds me.
Would someone explain the shifting operations in the following code snippet:
std::vector<bool> a;
a.push_back(true);
a.push_back(false);
//...
for (auto it = a.begin(); it != a.end();) // see 0x for meaning of auto
{
unsigned b = 0;
f...
it is a little bit strange to me that boost.asio doesn`t use basic concept when client app connecting to the server - using IP address and port. May be I am a little bit noobie in Boost - and I accept that - but anyway I do not understand.
So, I have code like this to get client connected to the server on the localhost:
boost::...
I need to convert string to support multi-language messaging in my client-server app.
Can I find it in boost?
...
Hello,
I want to check that all my memory was freed ok in Visual Studio 2008 in C++. I heard that I can add few includes and maybe write some code line and that should do it.
Does anyone know how I can do it?
Thanks in advance,
Greg
...
All the work I've done in C++ have either been to small to require a good debugger or been on windows so I've used Visual Studio at work.
Now I'm faced with a situation where I need to write some C++ while being on Ubuntu, so after looking over some of the alternatives I have when picking between the IDEs I can honestly say I don't have...
I am trying to use cywin to get some linux code building on a win32 machine.
I get the following VS.net 2003 error in ym compiler:
"c:\cygwin\usr\include\sys_types.h(15): error C2144: syntax error : '__int64' should be preceded by ';'
"
and
c:\cygwin\usr\include\sys_types.h(15): error C2501: 'extension' : missing storage-class or ty...
Our win32 applications (written in C++) have been around for over 10 years, and haven't been updated to follow "good practices" in terms of where they keep files. The application defaults to installing in the "C:\AppName" folder, and keeps application-generated files, configuration files, downloaded files, and saved user documents in sub...
Is there a way to detect IP address changes on the local machine in Linux programmatically using C++?
...
Hello,
I am writing a simulation and need some hint on the design. The basic idea is that data for the given stochastic processes is being generated and later on consumed for various calculations. For example for 1 iteration:
Process 1 -> generates data for source 1: x1
Process 2 -> generates data for source 1: x2
and so on
Later...
I am looking for more examples that compile under both C (any standard) and C++, but run differently. As an example, I found this in comp.lang.c, which produces 8 for C, and 512 for C++:
#include <stdio.h>
struct A { char block[8]; };
int main(void) {
struct B {
struct A {
char block[512];
} a;
};
...
I'm using an object to start boost thread and it has some public member variables which I modify in the thread (in the () operator). How can I access the object's member variables from outside the thread?
I tried using a mutex (defined in the object's class) that is locked both in the operator() of the object and from outside, but it do...
I understand that there is a resource hit from using RTTI, but how big is it? Everywhere I've looked just says that "RTTI is expensive," but none of them actually give any benchmarks or quantitative data reguarding memory, processor time, or speed.
So, just how expensive is RTTI? I might use it on an embedded system where I have only ...
I have a collection of polymorphic objects, all derived from my Animal class: Cat, Dog, and MonkeyFish.
My usual mode of operation is to store these objects in a vector of Animal pointers, like so:
std::vector< Animal * > my_vector;
my_vector.push_back( new Animal_Cat() );
my_vector.push_back( new Animal_Dog() );
my_vector.push_back(...
I've discovered while trying to use a luaBind-style class binding system that passing pointers to member variables doesn't seem to work right when compiling as a 64 bit app. Specifically:
class Foo {
int a;
int b;
};
With the above class getting &Foo::b in 32 bit will return (as expected) 0x00000004. The same call in 64 bit re...