c++

How to use parsers like lex or yacc in c++

Hi, I want to parse the strings, so that to check whether they have specified syntax or not. Ex: Str = Z344-R565l t Here my requirement is after z there should be a number and after that a "-" and after that R should be there followed by a number, followed by "l", followed by a space and then finally "t". If any thing other than this ...

C++0x: Range overloads for standard algorithms?

std::sort(range(c)); as opposed to std::sort(c.begin(), c.end(); Do you expect the next standard to provide range overloads for standard algorithms? Boost's range iterators are something similar, and Bjarne Stroustrup's iseq()s mentioned in TC++PL3e are also the same idea. I have looked at the latest draft I could find but didn't ...

Unix Command For Benchmarking Code Running K times

Hi, Suppose I have a code executed in Unix this way: $ ./mycode My question is is there a way I can time the running time of my code executed K times. The value of K = 1000 for example. I am aware of Unix "time" command, but that only executed 1 instance. ...

Publish/Subscribe and Smart pointer

I would like to implement a simple Publish/Subscribe pattern where: A single publisher publishes a token (a pointer to an object) to its subscribers. Publisher and subscribers are all independent threads. I plan to add thread-safe queue to each of the subscriber such that Publisher can keep distributing the tokens to the subscribers whi...

gcc equivalent of VC++ warning C4018: signed/unsigned mismatch

Is there a gcc equivalent of VC++ warning C4018: signed/unsigned mismatch? We have an automated build on windows which runs with /WX and I'd like to be able to catch those warnings when building on Linux as well. ...

How else to achieve "templated function pointers"?

Is it possible to establish a set of templated function pointers, without the hassle of doing so manually? Here's an example to illustrate what the heck I'm talking about. Let's say I have a frequently-called function "write" of which I have two implementations (write0 and write1) that I'd like to be able to switch between dynamically....

How does one disassemble Pro*C/C++ programs?

Is there a way to disassemble Pro*C/C++ executable files? ...

How to configure and run a fastcgi application using Lighthttpd...

Hi, i've installed Lighthttpd for windows and i'd created a simple program in c++ which uses fastcgi libraries. i'll post the code here... #include "fcgi_stdio.h" #include <stdlib.h> int count; void initialize(void) { count=0; } void main(void) { initialize(); while (FCGI_Accept() >= 0) { printf("Content-type: text/html\r\n...

What are the often misunderstood concepts in C++?

What are the often misunderstood concepts in c++? ...

Problems writing a copy constructor for a smart pointer

The code I'm working with has its own smart pointer implementation which does simple reference counting. Yes, we shouldn't have our own implementation. Yes, we should be using one from boost or some such. Bear with me. I found I wanted to write code like this: ... CountedPointer<Base> base; ... CountedPointer<Derived> derived; ... base...

OpenGL in C++ - Crashes at runtime

Hi, I'm working on some OpenGL in C++ in Visual Studio 2005. // SetUpOpenGL sets the pixel format and a rendering // context then returns the RC HGLRC COpenGLBaseWnd::SetUpOpenGL(HWND hwnd) { static PIXELFORMATDESCRIPTOR pfd = { sizeof (PIXELFORMATDESCRIPTOR), // strcut size 1, /...

A question about sizeof and class member function.

class B { public: int a; void fn(); } If I create an object of B, using B* pb = new B; Where is the memory of fn() locate? Is there a pointer in object that pointing at the memory loaction of fn()? If yes, why sizeof(B) returns the value as if there is no pointer in object at all? ...

How do I write data over an ethernet connection to an IP:Port address?

I have a need to write a quick and dirty application to write some data over an ethernet connection to a remote machine. The remote machine is sitting waiting for data, and I just want to blat some data at it to test the connection and bandwidth etc. I'd like to be able to, say, send a known pattern of data (simple counting or repeating...

What is more efficient i++ or ++i?

Exact Duplicate: Is there a performance difference between i++ and ++i in C++? Exact Duplicate: Why should I use ++i? Exact Duplicate: Difference between i++ and ++i in a loop? What is more efficient i++ or ++i? I have only used this in Java and C/C++, but I am really asking for all languages that this is implemented in. In colleg...

Does every object of virtual class have a pointer to vtable?

Does every object of virtual class have a pointer to vtable? Or only the object of base class with virtual function has it? Where did the vtable stored? code section or data section of process? ...

partial template specialization for dynamic dispatch

...

What is the difference between WCHAR and wchar_t

I was wondering if there was any practical difference between WCHAR and wchar_t. ...

What are some C++ Standard Library usage best practices?

I'm learning C++ and the book I'm reading (The C++ Programming Language) says to not reinvent the wheel, to rely on the standard libraries. In C, I often end up creating a linked list, and link list iteration over and over again (maybe I'm doing that wrong not sure), so the ideas of containers available in C++, and strings, and algorithm...

Determining exception type after the exception is caught?

Is there a way to determine the exception type even know you caught the exception with a catch all? Example: try { SomeBigFunction(); } catch(...) { //Determine exception type here } ...

typedef std containers?

I wanted to do typedef deque type; //error, use of class template requires template argument list type<int> container_; But that error is preventing me. How do I do this? ...