boost

open_or_create flag doesn't works in boost library shared memory.

Hello Everybody, I am using boost library for sharing maps from one process to another using Shared Memory concept. Its working fine for me for the first time, but if the shared memory object is already present, then it just crashes. So, I have modified my code to use open_or_create flag and am expecting it to work, but still it cra...

Access Iterator in BOOST_FOREACH loop

I have a BOOST_FOREACH loop to iterate over a list. Unfortunately, I also need to cache an iterator to a particular item. typedef List::iterator savedIterator; BOOST_FOREACH(Item &item, list) { // stuff... if (condition) savedIterator = &item; // this won't work // do more stuff... } Obviously I can do this using a list.b...

best practice when returning smart pointers

What is the best practice when returning a smart pointer, for example a boost::shared_ptr? Should I by standard return the smart pointer, or the underlying raw pointer? I come from C# so I tend to always return smart pointers, because it feels right. Like this (skipping const-correctness for shorter code): class X { public: boost::...

learning c++ from boost library source code

I am very interested in c++ and want to master this language. I have read a lot of books about c++. I want to read some library source code to improve my skill, but when I read the boost library source code, I find it is very difficulty. Can anyone give me some advice about how to read boost source code and before I can understand it w...

Pointer to an element in boost pointer container

I am just starting to use boost::ptr_vector. I have a ptr_vector pctr as a member of one class A and want another class B to refer to an element in pctr. While constructing an object of class B I want to store a pointer in pctr. Since pointer containers do not allow access to the pointer (but only to references), I must take the addres...

Can't compile code using Boost graphviz.hpp

I'm trying to use read_graphviz extension to pull a graphviz .dot file into a Boost Grpah. Here is my sample. I can't get it to compile. I posted the g++ error message after the code but I had to but it short, it's too long to post here without significant re-formatting. The documentation the graphviz.hpp library is too terse to guid...

Example for boost shared_mutex (multiple reads/one write)?

I have a multithreaded app that has to read some data often, and occasionally that data is updated. Right now a mutex keeps access to that data safe, but it's expensive because I would like multiple threads to be able to read simultaneously, and only lock them out when an update is needed (the updating thread could wait for the other thr...

ACE vs Boost vs POCO

I have been working with the Boost libraries for quite some time. I absolutely love boost asio library for network programming. However I was introduced to two other libraries: POCO and ACE framework. I would like to know the good and bad of each. ...

C++: Problem with ptr_multimap::insert

Please consider the following code: #include "boost/ptr_container/ptr_map.hpp" int main() { typedef boost::ptr_multimap<char, const int> M; M m; char c = 'c'; int* j = new int(7); m.insert(c, j); return 0; } The gcc 4.3.3 compiler fails to compiler the above code. Am I doing something w...

Teach emacs recognize Boost.Test errors

This is an output of Boost.Test when test case failes: bjam toolset=msvc ...patience... ...found 1287 targets... ...updating 4 targets... compile-c-c++ ..\bin\test\Function.test\msvc-8.0\debug\link-static\threading-multi\Function.obj Function.cpp msvc.link ..\bin\test\Function.test\msvc-8.0\debug\link-static\threading-multi\Function.ex...

Does a Boost test suite exist?

I'm working on building the Boost platform for a currently unsupported toolchain. Obviously we'd like to verify that the compiler is building everything OK, so we've some measure of how successful the porting is going. However it's not immediately clear whether or not Boost has such a test suite, good ol' Google fails me (or I fail at Go...

Is there a problem with this usage of boost condition code?

Will this code ever wait on the mutex inside the producer's void push(data)? If so how do I get around that? boost::mutex access; boost::condition cond; // consumer data read() { boost::mutex::scoped_lock lock(access); // this blocks until the data is ready cond.wait(lock); // queue is ready return data_from_queue(); } //...

good combination of a c++ toolkit/library, cross platform db (not necessarily sql)

Hi what do you suggest as a cross platform "almost all encompassing" abstraction toolkit/library, not necessarily gui oriented? the project should at some point include an extremely minimal web server and a "db" of some sort (basically to have indexes/btrees, maybe relations, so a rdbms is desiderable but avoidable if necessarily, sql ...

Boost and XML (c++)

Hi, Is there any good way (and a simple way too) using boost to read and write xml files? I can't seem to find any simple sample to read xml files using boost? (can you point me some simple sample that use boost for reading and writing xml files) If not boost, is out there any good and simple library to read and write xml files that y...

Detecting when an object is passed to a new thread in C++?

I have an object for which I'd like to track the number of threads that reference it. In general, when any method on the object is called I can check a thread local boolean value to determine whether the count has been updated for the current thread. But this doesn't help me if the user say, uses boost::bind to bind my object to a boost:...

Thread-safe static variables without mutexing?

I remember reading that static variables declared inside methods is not thread-safe. Dog* MyClass::BadMethod() { static Dog dog("Lassie"); return &dog; } My library generates C++ code for end-users to compile as part of their application. The code it generates needs to initialize static variables in a thread-safe cross-platform ma...

boost exceptions

Do all boost exceptions derive from std::exception? If not do they all derive from some base exception class? ...

Whats the syntax to use boost::pool_allocator with boost::unordered_map?

I'm just experimenting with boost::pool to see if its a faster allocator for stuff I am working with, but I can't figure out how to use it with boost::unordered_map: Here is a code snippet: unordered_map<int,int,boost::hash<int>, fast_pool_allocator<int>> theMap; theMap[1] = 2; Here is the compile error I get: Error 3 error C2064...

How do I know who holds the shared_ptr<>?

I use boost::shared_ptr in my application in C++. The memory problem is really serious, and the application takes large amount of memory. However, because I put every newed object into a shared_ptr, when the application exits, no memory leaking can be detected. There must be some thing like std::vector<shared_ptr<> > pool holding the r...

Why is this boost header file not included

...