c++

Process Management Solution

Hi All, I'm working on a project that requires a process management solution much like init.d but with the following requirements: 1) Working with Windows not Linux 2) Must be able to start/stop/restart programs written in heterogeneous languages. 3) Must be able to extend process manager to start / stop processes depending on run-mode...

Why is partial specialziation of a nested class template allowed, while complete isn't?

template<int x> struct A { template<int y> struct B {};. template<int y, int unused> struct C {}; ...

How can I convert Perl regular expressions to boost regular expressions?

What is equivalent to perl expression: /ing$|ed$|en$/ in boost regular expression? Words end with ing or ed or en should match with reg expression in boost! ...

How to find string in a string

I somehow need to find the longest string in other string, so if string1 will be "Alibaba" and string2 will be "ba" , the longest string will be "baba". I have the lengths of strings, but what next ? char* fun(char* a, char& b) { int length1=0; int length2=0; int longer; int shorter; char end='\0'; while(a[i] != tmp) { i++; le...

File copying issue while converting to LPCTSTR

// Convert to a wchar_t* size_t origsize = strlen(toChar) + 1; const size_t newsize = 100; size_t convertedChars = 0; wchar_t wcstring[newsize]; mbstowcs_s(&convertedChars, wcstring, origsize, toChar, _TRUNCATE); wcscat_s(wcstring, L"\\*.*\0"); wcout << wcstring << endl; // C:\Documents and Settings\softnotions\Desktop\Release\*.*...

Nullable values in C++

I'm creating a database access layer in native C++, and I'm looking at ways to support NULL values. Here is what I have so far: class CNullValue { public: static CNullValue Null() { static CNullValue nv; return nv; } }; template<class T> class CNullableT { public: CNullableT(CNullValue &v) : m_Value(T(...

Exemple where TYPE_ALIGNMENT() fails

Hi, I have a question relating to alignment in c/c++. In http://stackoverflow.com/questions/364483/determining-the-alignment-of-c-c-structures-in-relation-to-its-members Michael Burr posted this Makro: #define TYPE_ALIGNMENT( t ) offsetof( struct { char x; t test; }, test ) in the comments someone wrote this might fail with non POD ...

What's the bug in the following code ?

#include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int, 4> a = {45, 11, 67, 23}; std::vector<int> v(a.begin(), a.end()); std::vector<int> v2; std::transform(v.begin(), v.end(), v2.begin(), boost::bind(std::multiplies<int>(), _1, 2)); st...

Eclipse CDT: cannot debug or terminate application

I have Eclipse set up fairly nicely to run the G++ compiler through Cygwin. Even the character encoding is set up correctly! There still seems to be something wrong with my configuration: I can't debug. The pause button in the debug view is simply disabled, and no threads appear in my application tree. It seems that gdb is simply not co...

How to call a function from a shared library?

What is the easiest and safest way to call a function from a shared library / dll? I am mostly interested in doing this on linux, but it would be better if there were a platform-independent way. Could someone provide example code to show how to make the following work, where the user has compiled his own version of foo into a shared lib...

Projects in XCode

Can i create a single project in XCode such that there are 2 targets, one using C++ and another using Objective-C?? ...

I serialized a C++ object, how to allocate memory for it without knowing what type it is?

Hello, I have serialized a C++ object and I wish to allocate space for it, although I can't use the "new" operator, because I do not know the object's class. I tried using malloc(sizeof(object)), although trying to typecast the pointer to the type the serialized object is of, the program shut down. Where is the information about the obje...

Infinity in MSVC++

I'm using MSVC++, and I want to use the special value INFINITY in my code. What's the byte pattern or constant to use in MSVC++ for infinity? Why does 1.0f/0.0f appear to have the value 0? #include <stdio.h> #include <limits.h> int main() { float zero = 0.0f ; float inf = 1.0f/zero ; printf( "%f\n", inf ) ; // 1.#INF00 print...

this pointer to base class constructor?

I want to implement a derived class that should also implement an interface, that have a function that the base class can call. The following gives a warning as it is not safe to pass a this pointer to the base class constructor: struct IInterface { void FuncToCall() = 0; }; struct Base { Base(IInterface* inter) { m_inter = int...

In what order does evaluation of post-increment operator happen?

Given std::vector<CMyClass> objects; CMyClass list[MAX_OBJECT_COUNT]; Is it wise to do this? for(unsigned int i = 0; i < objects.size(); list[i] = objects.at(i++)); Or should I expand my loop to this? for(unsigned int i = 0; i < objects.size(); i++) { list[i] = objects.at(i); } ...

Arrays multiplication

How to write arrayt multiplication (multiplicating two matrieces ie 3x3) of arrays of known size in c++ ? What will be the difference using pointers and reference ? ...

How to create Visual studio solution from make files ?

Hi all!! I have a source code for a project with their make files. I want to create a Visual Studio (2005) solution from it. Is there any direct way to do this? can anyone help me please. I spent hours for searching, but couldn't find a way to do this. Thanks. ...

What causes this LNK2019 error with COIN-OR?

Hello - I am trying to run Osiexample.cpp from COIN-OR (open-source software for numerical optimization) in MS Visual Studio 2008 and get the error message below. Linking... CoinOR Example.obj : error LNK2019: unresolved external symbol "public: __thiscall OsiClpSolverInterface::OsiClpSolverInterface(void)" (??0OsiClpSolverInterface@@Q...

BOOST program_options: parsing multiple argument list.

Hello, I would like to pass the multiple arguments with positive or negative values. Is it possible to parse it? Currently I have a following initialization: vector<int> IDlist; namespace po = boost::program_options; po::options_description commands("Allowed options"); commands.add_options() ...

Could the assign function for containers possibly overflow?

I ran into this question today and thought I should post it for the community's reference and/or opinions. The standard C++ containers vector, deque, list, and string provide an assign member function. There are two versions; I'm primarily interested in the one accepting an iterator range. The Josuttis book is a little ambiguous with ...