c++

How can you disable the buffer in a boost::iostreams sink?

Hi all, I've written a 'sink' using boost::iostreams, so that I can essentially have my own code run when someone tries to write to an iostream object. Unfortunately there is a buffer somewhere in the system, so that my Sink's write() function only gets called every 4kB or so. This is a problem because the sink I am implementing is a ...

Serialization of vectors in C++

Hello All, I'm trying to serialize a set of structs in C++. This works great for all data except a vector contained in my struct. I can write the data to disk, and then read all data back into memory. The only problem is when I try to access an element of the vector I get a segmentation fault. My code is below. Any help is greatly appre...

What is OpenMP?

What's a high-level description of OpenMP? The Wikipedia article states that "OpenMP (Open Multi-Processing) is an application programming interface (API) that supports multi-platform shared memory multiprocessing programming in C, C++ and Fortran on many architectures, including Unix and Microsoft Windows platforms. It consists of a se...

How to change the control themes in a Win32 API application?

If I create a button in the Win32 API, the default conrol theme looks like a Windows 95/98 button. I remember in the past the Microsoft forums told me how to get the XP style, but I don't recall how to do this. Is there a way to programatically or manually change the control themes in a Win32 application? Thanks. ...

Default constructor and virtual inheritance

Is possible to have virtual inheritance for class not providing default constructor? The present diamond diagram (the simplest one with the only change of no default constructor provided) does not compile (g++ 4.4.3). class A { public: A(int ) {} }; class B : virtual public A { public: B(int i) : A(i) {} }; class C : virtual pub...

char four[4] = "four"; What are the correct semantics for this statement?

int main(void) { char four[4] = "four"; return 0; } When compiled as a C++ program, G++ reports xxx.cpp: In function int main(): xxx.cpp:3: error: initializer-string for array of chars is too long When compiled a a C program, GCC reports no error. It appears to me, that the assignment is correctly copying all 4 bytes into t...

Is it OK to initialize a reference member with dynamically allocated memory?

Am I causing a memory leak here or is it OK to do like this? Should I use a smart pointer member instead of a reference? class A { public: A() : b_(*(new B)) {} private: B& b_; }; int main() { A a; return 0; } ...

Equivalent of C++ STL container "pair<T1, T2>" in Objective-C?

Hi guys, I'm new to Objective-C, so please don't judge me too much. I was wondering: Is there an equivalent of the C++ STL pair container I can use in Objective-C? I want to build an array that contains an NSInteger associated to an NSBool. I know I could use an array with each entry being a NSDictionary with a single key-value but I f...

Is there any Visual C++ compiler for linux supporting most of VS Visual C++?

Is there any Visual C++ compiler for linux supporting most of VS Visual C++? If there is no such what is best alternative for porting\adapting your visual C++ code to? ...

How can I expose a uniform interface to a template class ?

Hi everyone, I have implemented a templated buffer class like this: template <class T, class Impl> class base_hardware_buffer : Impl { public: typedef const T& const_reference; typedef T* pointer; void push_back(reference r) { // Do some generic operation, call impl when needed // ... } pointer...

STL containers , remove object from two containers

Hello . Suppose I have two containers , holding pointers to objects ,which share some of their elements . from http://www.cplusplus.com/reference/stl/list/erase/ it says that : This effectively reduces the list size by the number of elements removed, calling each element's destructor before. How can I remove an object from b...

Using std::vector<T*>::push_back with std::mem_fun and std::bind1st

I'm trying to use std::vector<T*>::push_back with std::mem_fun and std::binder1st, but it doesnt seem to be feasible, can this be done? I've tried to exemplify with the code below. #include <vector> #include <functional> #include <iostream> using namespace std; struct A { int _Foo; virtual int AFoo() { return _Foo; }...

SPSS 15 I/O DLL: Modifying Existing Cases

Hello, I am writing an application in C++ that interfaces with SPSS 15 using their I/O DLL. Our SPSS database is made of a number of cases, each with their unique "ID" field. What I need to do is open the database in read/write, find the case with the matching ID and modify some of the variables according to CSV files that my program p...

Detecting a drag operation from another application

I have an application that runs elevated (yes, it has to be elevated) but it needs to detect when another application is dragging an object over it. My application doesn't care what the object is, it doesn't want to receive the object, it just needs to know if something is being dragged. In a normal application this isn't an issue, but b...

Program portability

How to make sure that my program will be fully portable? ...

What are general steps for me to port my project to mono?

I have a dll. and visual C++ source for it. (my dll is visual c++ wraper around some ffmpeg av* libs - another precompiled dll's) while in the same solution (.sln) I have C# project that uses my dll. what are general steps for me to port my project to mono? ...

Hide class type in header

I'm not sure if this is even possible, but here goes: I have a library whose interface is, at best, complex. Unfortunately, not only is it a 3rd-party library (and far too big to rewrite), I'm using a few other libraries that are dependent on it. So that interface has to stay how it is. To solve that, I'm trying to essentially wrap the...

Documenting namespaces that span multiple files doxygen

Consider I have 2 header files. // HEADER 1 /** * Doc for Foo here? */ namespace Foo { class This {...}; } && // HEADER 2 /** * Doc for Foo here? */ namespace Foo { class That {...}; } How should I handle this when documenting with Doxygen? ...

Need beginner help with C++ syntax

I am busy with an assignment an I am getting an error from the compiler. I've got 4 yrs C# experience nil in C++. I'm getting the error "Invalid conversion from nodeType, initializing argument 1 of void linkedListType::deleteNode(const Type&) [with Type = int]' " on the line deleteNode(current->link); of this function: template<class...

Need help replacing swprintf

I am using some cross platform stuff called nutcracker to go between Windows and Linux, to make a long story short its limited in its support for wide string chars. I have to take the code below and replace what the swprintf is doing and I have no idea how. My experience with low level byte manipulation sucks. Can someone please help me ...