boost

Fully thread-safe shared_ptr implementation

Does anybody know of a fully thread-safe shared_ptr implementation? E.g. boost implementation of shared_ptr is thread-safe for the targets (refcounting) and also safe for simultaneous shared_ptr instance reads, but not writes or for read/write. (see Boost docs, examples 3, 4 and 5). Is there a shared_ptr implementation that is fully th...

Using Boost's graph breadth_first_search() to find a path in an unweighted, undirected graph

I'm using an adjacency_list graph, with undirected and unweighted edges. I need to find a shortest path between vertex u and vertex v. Should I use breadth_first_search() starting from u? When reaching v, how do I obtain the path, and how do I stop the search? thanks! ...

Boost::multi_array performance question

I am trying to compare the performance of boost::multi_array to native dynamically allocated arrays, with the following test program: #include <windows.h> #define _SCL_SECURE_NO_WARNINGS #define BOOST_DISABLE_ASSERTS #include <boost/multi_array.hpp> int main(int argc, char* argv[]) { const int X_SIZE = 200; const int Y_SIZE = ...

Why do locks work?

If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions? I thought that boost::mutex::scoped_lock should be at the beginning of each of my functions so the local variables don't get modified unexpectedly by another thread, is that correct? What if two threads are tryi...

How do I perform a nonblocking read using asio?

I am attempting to use boost::asio to read and write from a device on a serial port. Both boost::asio:read() and boost::asio::serial_port::read_some() block when there is nothing to read. Instead I would like to detect this condition and write a command to the port to kick-start the device. How can I either detect that no data is availa...

Can you use Boost.Regex to parse a stream?

I was playing around with Boost.Regex to parse strings for words and numbers. This is what I have so far: #include <iostream> #include <string> #include <boost/foreach.hpp> #include <boost/regex.hpp> #include <boost/range.hpp> using namespace std; using namespace boost; int main() { regex re ( "(" "([a-z]+)...

boost weak_ptr_cast in shared_from_this()

I'm using boost's shared pointers, and enable_shared_from_this to enable returning a shared pointer to this. Code looks like this: class foo : public boost::enable_shared_from_this<foo> { boost::shared_ptr<foo> get() { return shared_from_this(); } } Why would shared_from_this throw a weak_ptr_cast exception? ...

How to use BOOST_FOREACH with a boost::ptr_map?

How can I use BOOST_FOREACH efficiently (number-of-character/readability-wise) with a boost::ptr_map? Kristo demonstrated in his answer that it is possible to use BOOST_FOREACH with a ptr_map, but it does not really save me any typing (or makes my code really more readable) than iterating over the ptr_map with an iterator: typedef bo...

Problem Linking Boost Filesystem Library in Microsoft Visual C++

Hello. I am having trouble getting my project to link to the Boost (version 1.37.0) Filesystem lib file in Microsoft Visual C++ 2008 Express Edition. The Filesystem library is not a header-only library. I have been following the Getting Started on Windows guide posted on the official boost web page. Here are the steps I have taken: ...

shared_ptr in std::tr1

I am working on a platform with a gcc compiler however boost cannot compile on it. I am wondering what is the proper way to include the shared_ptr in std:tr1 on gcc? the file i looked in said not to include it directly, from what i can tell no other file includes it either :| ...

Have you ever obtained a significant speedup by using boost::pool ?

I've played with boost::pool a few times in places where it seemed to me I was seriously hammering the heap with a lot of object "churn". Generally I've used boost::object_pool, or boost::pool_alloc as an STL template parameter. However the result is invariably that performance is virtually unchanged, or significantly worsened. I'm cu...

boost vs ACE C++ cross platform performance comparison?

I am involved in a venture that will port some communications, parsing, data handling functionality from Win32 to Linux and both will be supported. The problem domain is very sensitive to throughput and performance. I have very little experience with performance characteristics of boost and ACE. Specifically we want to understand wh...

Boost Serialization using polymorphic archives

I am working on a client-server application that uses boost::serialization library for it's serialization needs. I need to serialize and deserialize polymorphic objects that does not seem to work. The documentation does say that it is supported but none of the related examples demonstrate what I'm trying to do here. So, I am not very ...

How to execute a command and get output of command within C++?

I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the system() function, but that will just execute a command. Here's an example of what I'm looking for: std::string result = system( "./some_command" ) ; I need to run an arbitrary command and get it's output. I've...

Unit-tests for Boost.Spirit

Hi I'm new to Boost.Spirit and Boost.Test and I would like to know how you verify the correctness of your grammars. Below is a simplified version of how I do it at the moment and I'm pretty sure that there's a better way: Each test case hase a pair of two strings containing the text to parse and the expected result delimited by semicol...

What is an analog for win32 file locking in boost::interprocess?

What sync mechanism should I use to give exclusive access to the text file in boost? The file will likely be accessed by threads from only one process. ...

boost::interprocess between Windows service and user application.

Hi, I'm using boost::interprocess to communicates between two applications. When the two applications are launch by the same user, it works great. When one of the application is a service, it fails. I found that the shared media is in fact a file that is created in the "TMP" directory. So it fails because each application is creatin...

Including boost::filesystem produces linking errors

Ok first off, I am linking to boost_system and boost_filesystem. My compiler is a custom build of MinGW with GCC 4.3.2 So when I include: #include "boost/filesystem.hpp" I get linking errors such as: ..\..\libraries\boost\libs\libboost_system.a(error_code.o):error_code.cpp: (.text+0xe35)||undefined reference to `_Unwind_Resume'...

Building Boost for static linking (MinGW)

I'm building Boost (I'm using System and FileSystem) for MinGW using bjam: bjam --toolset=gcc stage And it builds fine, but I want to be able to statically link to it (I have to have a single file for the final product) so I tried: bjam --link=static --toolset=gcc stage But I get the same output. Any ideas? edit second question in...

A more natural boost::bind alternative?

Don't get me wrong: Boost's bind() is great. But I do hate to write&read code with it, and I've given up hope my coworkers will ever grok/use it. I end up with code like this: btn.clicked.connect(bind(&BetBar::placeBet, this, bet_id)); animator.eachFrame.connect(bind(&Widget::move, buttons[bet_id])); Which, while logical, is very fa...