c++

c++ tokenize a string and include delimiters

I'm tokening with the following, but unsure how to include the delimiters with it. void Tokenize(const string str, vector<string>& tokens, const string& delimiters) { int startpos = 0; int pos = str.find_first_of(delimiters, startpos); string strTemp; while (string::npos != pos || string::npos != startpos) { ...

What is easiest way to create multithreaded applications with C/C++?

What is the easiest way to create multithreaded applications with C/C++? ...

boost::asio::ip::tcp::socket is connected?

I want to verify the connection status before realize my operations (read/write). Is there a way to make an isConnect() method? I saw this, but it seems "ugly". I tested is_open() function also, but doesn't have the expected behavior. Thanks ...

How to stop MFC from disabling my controls if I don't declare a message map entry for it's corresponding command?

Hi, I have the following problem: MFC is disabling my toolbar (a CToolbar) controls if I don't have a message map entry for it's corresponding message (let's say ID_MYBUTTON1). Is there a way around this? I had the same problems with the menu but I found that you could disable the auto disabling by setting CFrameWnd::m_bAutoMenuEnable t...

C++ image recognition library

I am trying to make a program to count colonies of bacteria using a camera. I will be writing it in C++ and need an image recognition library that is easy to setup. I will be using visual studios so a template would be nice. Any ideas? ...

Variable length template arguments list?

I remember seing something like this being done: template <ListOfTypenames> class X : public ListOfTypenames {}; that is, X inherits from a variable length list of typenames passed as the template arguments. This code is hypothetical, of course. I can't find any reference for this, though. Is it possible? Is it C++0x? ...

How to use hudson when building for multiple platforms

Right now we are building a number of C++ apps for Win32 platform. We will be soon porting to Linux and then maybe more (32 and 64 bits for both). What is the standard practice , do you use multiple hudson servers each on their own platform to do a build, or does the hudson service create VMs and do builds? It is not clear to me the...

convert string to argv in c++

I have an std::string containing a command to be executed with execv, what is the best "C++" way to convert it to the "char *argv[]" that is required by the second parameter of execv()? To clarify: std::string cmd = "mycommand arg1 arg2"; char *cmd_argv[]; StrToArgv(cmd, cmd_argv); // how do I write this function? execv(cmd_argv[0], ...

Differences between template specialization and overloading for functions?

So, I know that there is a difference between these two tidbits of code: template <typename T> T inc(const T& t) { return t + 1; } template <> int inc(const int& t) { return t + 1; } and template <typename T> T inc(const T& t) { return t + 1; } int inc(const int& t) { return t + 1; } I am confused as to what the f...

convert a pointer to a reverse vector iterator in STL

I have sort(arr, arr+n, pred); How do I sort in reverse order? ...

Is it possible to define a variable in expression in C++?

I have this insane homework where I have to create an expression to validate date with respect to Julian and Gregorian calendar and many other things ... The problem is that it must be all in one expression, so I can't use any ; Are there any options of defining variable in expression? Something like d < 31 && (bool leapyear = y % 4 =...

Visual Studio 2008 IDE - Static Linking a C Dll Library

I am experiencing Frustration ^ Frustraion with this %&$^& VS IDE. I am using Visual C++ 2008 3.5 SP1 (but I also have the pro edition if that is needed and I dont want to use loadlibrary()) I have a test Dll created in another language (basic not C in fact) that contains a CDECL function that adds an 'int' to a 'double'. I would really...

What are these GCC/G++ parameters?

Hello, everyone. I've been using the UVa Online Judge to solve some programming challenges, and, when submitting my solutions, I'm told the judge will compile my code using the following parameters to GCC/G++ that I don't know: -lm -lcrypt -pipe -DONLINE_JUDGE. What do they do? Thank you very much in advance! ...

Decent shared_ptr implementation that does not require a massive library?

I am taking a C++ programming class right now on GIS Programming. I am really starting to get alot of headaches from dealing with proper memory management. Considering at any time there is often 8-10 classes each holding a pointer to a 3D matrix or something else very large. Now our class already raised the issue of the prof allowing us ...

How can I display +/- icons on my tree view?

I want to make a tree view where items show a "+" icon when closed and a "-" icon when open. Just like the Windows XP explorer. However, I can't find out how to get the icons. Do I get them from the system or do I need to provide my own? ...

What does it mean when I "cannot convert X** to X*" in a "new" assignment?

In running Ubuntu and the g++ compiler I keep getting the same error from this code. myClass *arr; arr = new myClass*[myClassSize]; // line 24 for(int a = 0;a<myClassSize;a++) arr[a] = new myClass; Here is the error: cannot convert 'myClass **' to 'myClass *' in assignment The problem was on line 24. ...

What is the optimization level ( g++ ) you use while compairing two different algorithms written in C++ ?

I have two algorithms written in C++. As far as I know, it is conventional to compile with -O0 -NDEBUG (g++) while comparing the performance of two algorithms(asymptomatically they are same). But I think the optimization level is unfair to one of them, because it uses STL in every case. The program which uses plain array outperforms the...

What is the difference between int x=1 and int x(1) in C++?

Possible Duplicate: Is there a difference in C++ between copy initialization and assignment initialization? I am new to C++, I seldom see people using this syntax to declare and initialize a variable: int x(1); I tried, the compiler did not complain and the output is the same as int x=1, are they actually the same thing? Ma...

Notification when a thread is destroyed

Hi! Is there a way to get a notification that a thread no longer runs (has returned) in your application? I know this is possible in kernel mode (using PsSetCreateThreadNotifyRoutine), but is there a way to know this from user mode, using only Win32 API ? The problem is that I can't control the code in the thread, because my module i...

Sending IOCTL from IRQL=DISPATCH_LEVEL (KbFilter/KMDF)

I am using the KbFilter example in the WDK, trying to send an IOCTL in a function that is called by KbFilter_ServiceCallback and therefore is executed at DISPATCH_LEVEL. The function just has to send an IOCTL and return, am not waiting for an output buffer to be filled so it can be asynchronous, fire and forget. I am currently using the...