c++

How do you correctly use boost::make_shared_ptr?

This simple example fails to compile in VS2K8: io_service io2; shared_ptr<asio::deadline_timer> dt(make_shared<asio::deadline_timer>(io2, posix_time::seconds(20))); As does this one: shared_ptr<asio::deadline_timer> dt = make_shared<asio::deadline_timer>(io2); The error is: error C2664: 'boost::asio::basic_deadline_time...

Intel MKL memory management and exceptions

Hello everyone, I am trying out Intel MKL and it appears that they have their own memory management (C-style). They suggest using their MKL_malloc/MKL_free pairs for vectors and matrices and I do not know what is a good way to handle it. One of the reasons for that is that memory-alignment is recommended to be at least 16-byte and with...

C++ class object memory map

When we create an object of a class what does it memory map look like. I am more interested in how the object calls the non virtual member functions. Does the compiler create a table like vtable which is shared between all objects? class A { public: void f0() {} int int_in_b1; }; A * a = new A; What will be the memory map of a? ...

Problem related to dll

Hi all! Can anyone guide me what could be the problem in the mentioned below:- This PP folder is present in the following path at my desk "E:\WINCE600\PLATFORM\COMMON\SRC\SOC\COMMON_FSL_V2_PDK1_7\IPUV3" In this IPUV3 folder, PP folder is present which does the resize,rotation & conversion task of an image. This PP folder consists of...

C++ Blogs Worth Reading/Bookmarking

Possible Duplicate: C++ blogs that you regularly follow? Hi, What C++ related blogs are worth reading/bookmarking? e.g. blogs that you like you visit and real regularly for up to date information on C++, tips + tricks etc etc. ...

Adding an allocator to a C++ class template for shared memory object creation

In short, my question is: If you have class, MyClass<T>, how can you change the class definition to support cases where you have MyClass<T, Alloc>, similar to how, say, STL vector provides. I need this functionality to support an allocator for shared memory. Specifically, I am trying to implement a ring buffer in shared memory. Current...

what's the deal with compile time evaluation of constant arithmetic, and can it be done in the pre processor?

template <int T> void aFunc(){} int main() { int anArray[45-32]; switch(4) { case 4<45: break; } aFunc<4*3/7&8 == 45 - 5>(); } so this all compiles in VC++ 2005 is this standard? if so, what do the conditional operators return? 0 and 1? are there limits? and the thing that interests me the most, can...

Uneditable file and Unreadable(for further processing) file( WHY? ) after processing it through C++ Program

Hi...:) This might look to be a very long question to you I understand, but trust me on this its not long. I am not able to identify why after processing this text is not being able to be read and edited. I tried using the ord() function in python to check if the text contains any Unicode characters( non ascii characters) apart from the ...

C++ - Unwanted characters printed in output file.

This is the last part of the program I am working on. I want to output a tabular list of songs to cout. And then I want to output a specially formatted list of song information into fout (which will be used as an input file later on). Printing to cout works great. The problem is that tons of extra character are added when printing to fo...

C++0x atomic implementation in c++98 question about __sync_synchronize()

I have written the followin atomic template with a view to mimicing the atomic operations which will be available in the upcoming c++0x standard. However, I am not sure that the __sync_synchronize() call I have around the returning of the underlying value are necessary. From my understanding, __sync_synchronize() is a full memory barr...

C# :- P/invoke signature

I have a dll with following signature in C++. It is working in c++; void Decompress(unsigned char *in,int in_len,unsigned char * out, unsigned *o_len,int *e); Description of parameter *in : It is byte array passed to fucntion. in_len : Length of bytes in first parameter. *out : This would be the output as byte array. *o_len : N...

Block Access to physical address on Windows

I'm accessing my memory-mapped device via a device-specific physical memory on the PC. This is done using a driver that maps a specific physical address to a pointer in linear memory on my process address space. I wanted to know if there is any way I can obtain a block the specific physical address and prevent other processes or devices...

Is it possible in C++ to inherit operator() ?

I'm writing some examples of hash functions for hash_map. If I use a hash_map defined by my compiler, I need to define Comparer in Hasher. I know that it's better to use tr1::unordered_map but in my application it's important to set minimum number of buckets rather big and define mean bucket_size - a condition to grow. So I would like t...

protobuf-net - problem with deserializing on C++ side :(

Hi all (and Marc :) I am using ProtoBuf-Net in my .NET application to serialize the following : (in .proto format) message ProtoScreenBuffer { optional int32 MediaId = 1; optional bytes Data = 2; optional bool LastBuffer = 3; optional int64 StartTime = 4; optional int64 StopTime = 5; optional int32 Flags = 6; optional int32 BufferSubTy...

copy a map into another map

I have a map like this: map<prmNode,vector<prmEdge>,prmNodeComparator> nodo2archi; I need to have an identical copy of this map. How is the fast way to make this? I have tried this: map<prmNode,vector<prmEdge>,prmNodeComparator> copiamap( nodo2archi ); but it doesn't work. The copiamap is empty. Thank you very much ...

C++: implicit conversion between 3rd party types

There are two classes: A and B. There are algorithms for converting from type A to type B and back. We cannot touch the source code of them. Can I write an implicit conversion between the two types? Example code which should work: B CalculateSomething(double x) { A a(x); a.DoSomethingComplicated(); return a; } ...

Portable way to get file size in C/C++

I need to determin the byte size of a file. The coding language is C++ and the code should work with Linux, windows and any other operating system. This implies using standard C or C++ functions/classes. This trivial need has apparently no trivial solution. ...

Using Freetype2 in QT (QPixmap)

What should I do to to render sample string with specified font to the QPixmap? QT still cannot working with Type1 font, but it is required. My code: int e; e = FT_Init_FreeType(&library); e = FT_New_Face( library, "arial.ttf", 0, &face ); e = FT_Set_Char_Size( face, size << 6, size << 6, 96, 96 ); e = FT_Set_Pixel_S...

How to wait for a cloned child process of an invoked process to exit?

I have a program which needs to invoke a process to perform an operation and wait for it to complete the operation. The problem is that the invoked process clones itself and exits, which causes the wait api to return when the process exits. How can I wait for the cloned process to finish execution and return? I am using the windows JOB ...

Is qsort thread safe?

I have some old code that uses qsort to sort an MFC CArray of structures but am seeing the occasional crash that may be down to multiple threads calling qsort at the same time. The code I am using looks something like this: struct Foo { CString str; time_t t; Foo(LPCTSTR lpsz, time_t ti) : str(lpsz), t(ti) { } }; class Sort...