c++

Getting a negative NaN on g++ 4.4.3, is this standard?

I have g++ 4.4.3 on Linux with Ubuntu Lucid Lynx, and I am getting a: -nan as a result. On Hardy Heron with g++ 4.3.1, I am getting all nan This is causing my text diff regression to fail, since I am using cout to print this numerical result. What is the meaning of a signed nan, and is there a way to tell the compiler that an unsig...

Lambda capture as const reference?

Is it possible to capture by const reference in a lambda expression? I want the assignment marked below to fail, for example: #include <cstdlib> #include <vector> #include <string> #include <algorithm> using namespace std; int main() { string strings[] = { "hello", "world" }; static const size_t num_st...

Disable accelerator table itens in MFC

I need to temporarily disable a few items from an accelerator table when the input focus is on a CEdit field. My application has some commands associated with keyboard keys (A, S, D, etc.) and I need to disable those while the user is entering text in the field. ...

Using "unique()" on a vector of vectors in C++

I hope this is not a duplicate question, but if it is, feel free to point me in the right direction. I have a vector<vector<int> >. Is it possible to use unique() on this? Something like: vector<vector<int> > myvec; //blah blah do something to myvec vector<vector<int> >::interator it = unique(myvec.begin(), myvec.end()); Would the r...

Accepting nested variadic class templates as arguments to function template.

I'm trying to make a function template that will accept two (or more) of the nested variadic class templates listed below, as arguments, and put them into another data structure that will accept different types (pair or tuple is what I'll most likely use). Here are the classes and subclasses, along with the usage of my function (the fun...

Passing const char* as template argument

Why can't you pass literal strings in here? I made it work with a very slight workaround. template<const char* ptr> struct lols { lols() : i(ptr) {} std::string i; }; class file { public: static const char arg[]; }; decltype(file::arg) file::arg = __FILE__; // Getting the right type declaration for this was irritating, so I ...

What to use for typedef struct array in c++

I have been implementing a visual debugger in my application using another bit of source code. I ran into an issue when I stumbled across them using this.. struct DebugVertex { gkVector3 v; unsigned int color; }; typedef utArray<DebugVertex> Buffer; I found the free library that they are using for utArray, however I like to ...

Declare variables at top of function or in separate scopes?

Which is preferred, method 1 or method 2? Method 1: LRESULT CALLBACK wpMainWindow(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_PAINT: { HDC hdc; PAINTSTRUCT ps; RECT rc; GetClientRect(hwnd, &rc); hdc = BeginPa...

Any way to resolve C4772 errors without having to register DLLs?

I am maintaining a VS2010 project which has a number of cross-referenced COM libraries. I am trying to configure the project in such a way that it is buildable from a random workstation which has VS2010 installed. The workstation could be both 32 and 64 bit, so if I configure project to "register output", the build will fail to build on ...

Running Commandline

I'm trying to run a command from a window project using system() call but everytime the console shows up. how can i run the command without displaying a console window? ...

Get event viewer logs with win api in c++

My application need to save event viewer logs to a specified directory and it has to be done with win api. Application and System logs are required. EDIT: EvtExportLog - I found out that I can't use this function because minimal requirements are Win Server 2008, and I need this to work on Win Server 2000 and Win Server 2003. Any sugges...

CUDA Project Structure

The template and cppIntegration examples in the CUDA SDK (version 3.1) use Externs to link function calls from the host code to the device code. However, Tom's comment at http://stackoverflow.com/questions/2090974/how-to-separate-cuda-code-into-multiple-files#comment-2024913 indicates that the usage of extern is deprecated. If this the...

what is the simplest way to create edit box in c++

i need to create edit box in c++ without using mfc..... only win32 ...

Unit testing large non-member functions

Hey all, I have a function, which I'd like to get under test. However, it's very large and creates a finite state machine. The function looks roughly like: std::auto_ptr<IFiniteStateMachine> CreateFSM() { std::auto_ptr<IFiniteStateMachine> = apFSM( new CFiniteStateMachine() ); std::list<IState*> listStates; listState.pus...

Python vs Lua for embedded scripting/text processing engine

For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line. The application will require a fair amount of text processing and the use of regular expressions within these scripts. I know Lua is generally the industry darling when it comes to embedded scr...

difference between interface inheritance and implementation inheritance

I found those two terms in the book of Meyers, but what is the difference, thanks in advance for any help ...

Visual C++ 2008 - breakpoint cannot be hit

I am trying to dissect a legacy application through debugging, but I can't get the breakpoint to hit in certain places of the application. The application has a c# GUI frontend and a c++ backend. I am trying to put a breakpoint in a c++ project of the solution. There are a couple of c++ projects, but I cannot set a breakpoint in one of...

Which video codec should i use for generating my videos with OpenCV?

Hello, i am developing an application using opencv that manages a set of jpg images (user specifies the folder) and generates a video chronoconically based on EXIF date. my application must fullfilth the condition: 1) allow any fps value passed by user as parameter (any value between 1 and 100). at the moment i choosed the CV_FOURCC('...

C++ unhandled exceptions

Hello! Does C++ offer a way to 'show' something visual if an unhandled exception occurs? What I want to do is to make something like assert(unhandled exception.msg()) if it actually happens (like in the following sample): void foo() { throw std::exception("Message!"); } int main() { foo(); } I expect this kind of code not to te...

Which is better for local IPC, POSIX message queues (mqueues) or Unix domain (local) sockets?

Is it better to use POSIX message queues or Unix domain sockets for local IPC communication? I have worked with Unix sockets between machines (not domain) and I remember that making and breaking the connection would cause sockets to linger awhile before they finally went away. Moreover, if you wanted a "reliable" exchange you either had...