c++

HeapCreate, HeapAlloc in Linux, private allocator for Linux

Hi, In Windows, for very demanding applications, a programmer may use HeapCreate, HeapAlloc in order to better manage and control the allocation of memory- speed it up (aka private allocators). What is the equivalent in Linux c++ programming? ...

Can I add Boost source+header files to my own (Open Source) project?

Is it allowed by the Boost License to just add the source code of the stuff I need to my project (accompanied by the license of course?). I couldn't find any "descriptive" confirmation. I would have seperate Include/boost and Source/boost directories for easy access. PS: Seeing as boost::filesystem is going into C++0x TR2, and lambda, r...

How to simulate Func<T1, T2, TResult> in C++?

Hello all, In C#, I use Func to replace Factories. For example: class SqlDataFetcher { public Func<IConnection> CreateConnectionFunc; public void DoRead() { IConnection conn = CreateConnectionFunc(); // call the Func to retrieve a connection } } class Program { public void CreateConnection() { ...

Unresolved symbol when inheriting interface

It's late at night here and I'm going crazy trying to solve a linker error. If I have the following abstract interface: class IArpPacketBuilder { public: IArpPacketBuilder(const DslPortId& aPortId); virtual ~IArpPacketBuilder(); // Other abstract (pure virtual methods) here... }; and I instantiate it like this: class D...

Simple string parsing with C++

I've been using C++ for quite a long time now but nevertheless I tend to fall back on scanf when I have to parse simple text files. For example given a config like this (also assuming that the order of the fields could vary): foo: [3 4 5] baz: 3.0 I would write something like: char line[SOME_SIZE]; while (fgets(line, SOME_SIZE, file)...

[boost::filesystem] performance: is it better to read all files once, or use b::fs functions over and over again?

I'm conflicted between a "read once, use memory+pointers to files" and a "read when necessary" approach. The latter is of course much easier (no additional classes needed to store the whole dir structure), but IMO it is slower? I'm trying to list the filenames and relative paths (so the compiler can do with them what it needs to). A lit...

How to increase error limit in Visual Studio?

When building an app. VS will complain of exceeded error count: fatal error C1003: error count exceeds 100; stopping compilation Is there a way to increase the limit? Thanks in advance, - Oleksii Skidan ...

C++ Serialization Clean XML Similar to XSTREAM

I need to write a linux c++ app which saves it settings in XML format (for easy hand editing) and also communicates with existing apps through XML messages over sockets and HTTP. Problem is that I haven't been able to find any intelligent libs to help me, I don't particular feel like writing DOM or SAX code just to write and read some ve...

Get a char from a CString

I have created a function that has as input a char szMyChar; (using it in a switch statement). Now I have a CString having just a char, lets say CString strString = "A"; An option to call the function could be: if (strString == "A") CallMyFunc('A'); though it is clumsy. I tried atoi (returns 0) and casting though neither works. An...

Is the use of union in this matrix class completely safe?

Unions aren't something I've used that often and after looking at a few other questions on them here it seems like there is almost always some kind of caveat where they might not work. Eg. structs possibly having unexpected padding or endian differences. Came across this in a math library I'm using though and I wondered if it is a total...

How to find where program crashed

I have a program that crashes (attempting to read a bad memory address) while running the "release" version but does not report any problems while running the "debug" version in the visual studio debugger. When the program crashes the OS asks if I'd like to open up the debugger, and if I say yes then I see an arrow pointing to where I a...

How can I avoid encoding mixups of strings in a C/C++ API?

I'm working on implementing different APIs in C and C++ and wondered what techniques are available for avoiding that clients get the encoding wrong when receiving strings from the framework or passing them back. For instance, imagine a simple plugin API in C++ which customers can implement to influence translations. It might feature a fu...

How a member func can know *programmatically* the 'name of the object' that is calling it?

Let say we have a class MyClass that has and a memberfunc(). An object is created for this MyClass, say ObjA. i.e MyClass ObjA; ObjA calls memberfunc(). Can we get this name 'ObjA' inside memberfunc() programatically? Note: I know how to get the type of the object, i.e 'MyClass', using RTTI (Run-Time Type Identification), the sam...

Internal class and access to external members.

I have question with this same title here but now as I'll present in code below this seems to behave in the opposite way to the way explained to me in my first question with the same title. Ok code: class LINT_rep { private: char* my_data_; //stores separately every single digit from a number public: class Iterator:public iterat...

Doubt in Vptr -want to know how it is getting Vtable address

Hi all, i wanted to know how vptr getting vtable base address. for instance class A { virtual getdata(); int a; } now, A obj; /// here vptr getting vtable's base address. i wanted to know this mystery.. Thanks in advance ...

"Unhandled exception"/"Access violation writing location" error with referenced array pointers

I'm trying to fill a pointer matrix with values from a text file. It's a double pointer to a simple struct with 2 ints, time and tons. void get_changes(change** &c){ ifstream file("change_data_time.prn"); //data file, time only, size is the same as tons string line, var; //string placeholders for the getlines ...

Need help with BOOST_FOREACH/compiler bug

I know that boost or compiler should be last to blame, but I can't see another explanation here. I'm using msvc 2008 SP1 and boost 1.43. In the following code snippet execution never leaves third BOOST_FOREACH loop typedef Graph<unsigned, unsigned>::VertexIterator Iter; Graph<unsigned, unsigned> g; g.createVertex(0x66); // works fin...

Uses for the capacity value of a string

In the C++ Standard Library, std::string has a public member function capacity() which returns the size of the internal allocated storage, a value greater than or equal to the number of characters in the string (according to here). What can this value be used for? Does it have something to do with custom allocators? ...

C++ - Totally suspend windows application

Hello! I am developing a simple WinAPI application and started from writing my own assertion system. I have a macro defined like ASSERT(X) which would make pretty the same thing as assert(X) does, but with more information, more options and etc. At some moment (when that assertion system was already running and working) I realized ther...

C++ non-member functions for nested template classes

I have been writing several class templates that contain nested iterator classes, for which an equality comparison is required. As I believe is fairly typical, the comparison is performed with a non-member (and non-friend) operator== function. In doing so, my compiler (I'm using Mingw32 GCC 4.4 with flags -O3 -g -Wall) fails to find the ...