boost

space allocated by compressed_matrix in boost

How much space is allocated by boost compressed_matrix? Is it true that it only allocates space for non-zero elements? If this is true, I don't understand why the following code gives bad_alloc error. namespace bubla = boost::numeric::ublas; typedef double value_type; typedef bubla::compressed_matrix<value_type> SparseMatrix; unsign...

BJAM , building for vc-80 instead of vc7.1

How can i build a boost library date_time using bjam for vc80. currently I am using ..\bjam.exe release debug threa ding=multi --toolset=msvc-8.0 stage --with-date_time --build-type=complete --deb ug-configuration -d+2 This only generates libraries with the vc7.1 version, what I need is vc80. I also noticed that the v1 verion Boost.Bu...

How to locate "boost::noncopyable" errors??

With desperate battle with Boost.Asio, i met a lot of difficulties. One of them is that i can hardly locate where the "boost::noncopyable errors" are!! If i violate the noncopyable regulation accidently, IDE only shows me some errors in noncopyable.hpp or somewhere else but nowhere in my files. I can only find errors by comment&uncomm...

Creating an object on the stack then passing by reference to another method in C++

I am coming from a C# background to C++. Say I have a method that creates a object in a method on the stack, then I pass it to another classes method which adds it to a memeber vector. void DoStuff() { SimpleObj so = SimpleObj("Data", 4); memobj.Add(so); } //In memobj void Add(SimpleObj& so) { memVec.push_back(so); //boost...

How to call a member function on a parameter with std::for_each and boost::bind?

I want to add a series of strings to a combo box using std::for_each. The objects are of type Category and I need to call GetName on them. How can I achieve this with boost::bind? const std::vector<Category> &categories = /**/; std::for_each(categories.begin(), categories.end(), boost::bind(&CComboBox::AddString, &comboBox, _1); The c...

boost::python: Python list to std::vector

Finally I'm able to use std::vector in python using the [] operator. The trick is to simple provide a container in the boost C++ wrapper which handles the internal vector stuff: #include <boost/python.hpp> #include <vector> class world { std::vector<double> myvec; void add(double n) { this->myvec.push_back(n); }...

Using a boost signal within boost::bind.

I'm trying to wrap triggering for a boost::signal into a boost::bind object. So what I want is to invoke the signal with some pre-packaged arguments when the boost::function is called. What I have is this: boost::signals2::signal<void(int)> sig; boost::function<void()> f = boost::bind( &(sig.operator()), &sig, 10); But this doesn...

How to retrieve a reference from a boost ptr_vector?

I have two classes: an Object class, and an ObjectManager class. The ObjectManager class stores "Objects" via a ptr_vector container. There are some instances where I need to retrieve references to these stored pointers to perform individual actions on them. How would I go about doing so? Compilable Pseudo Code: #include <boost/ptr_con...

boost compressed matrix basics

I am confused on how the boost::compressed_matrix works. Suppose I declare the compressed_matrix like this: boost::numeric::ublas::compressed_matrix<double> T(1000, 1000, 3*1000); This allocates space for 3*1000 elements in a 1000x1000 matrix. Now how do I give it the locations which are the non-zero elements? When and how are the non...

portable threading APIs

Hi all, I know of three portable threading C++ APIs : Qt boost::thread GNU Pth Apart from possible licensing issues involved, how do these compare in: actual portability (mostly interested in Linux and Windows) capabilities programming ease-of-use support/development activity of the library And: are there more like these that a...

Thread synchronization with boost::condition_variable

Hello, I'm doing some experiments on C++ multithreading and I have no idea how to solve one problem. Let's say we have thread pool, that process user requests using existing thread and creates new thread, when no free thread available. I've created command_queue thread-safe class, which have push and pop methods. pop waits while queue i...

boost::asio::async_read and boost::asio::streambuf

I am using async_read with streambuf. However, I would like to limit the amount of data read to 4, so I can properly handle header before going to body. How can I do that using async_read? ...

C++: mixture between vector and list: something like std::rope?

Hi, When storing a bunch of items and I don't need random access to the container, I am using an std::list which is mostly fine. However, sometimes (esp. when I just push back entries to the back and never delete somewhere in the middle), I wish I had some structure with better performance for adding entries. std::vector is bad because...

Boost FOR_EACH Over A Ptr_Vector?

I'm currently having fun trying to learn some of the Boost libary. I'm currently doing what I guess will be a future homework project (semester hasn't started yet). However, this question is not about the homework problem, but about Boost. Code: /* AuctionApplication.h */ class AuctionApplication : boost::noncopyable { private: boo...

How to use boost::error_info correctly?

I'm trying to following the examples on this page: http://www.boost.org/doc/libs/1_40_0/libs/exception/doc/motivation.html The minute I try the following line: throw file_read_error() << errno_code(errno); I get an error: error C2440: '<function-style-cast>' : cannot convert from 'int' to 'errno_code' How do I get this to work?? ...

Sync only parts of a c++ vector using Boost.MPI

I have a std::vector (let's call it "data_vector") that I want to synchronize parts of across processors. I.e., I want to send the values from arbitrary indexes in that vector to other processors. I can easily do this with Boost's send() functions if I want to send the whole vector, but I really only need to send a small portion of it. ...

parsing of date/time from string (boost?)

I'm kinda stuck with parsing of date/time strings. Help would be greatly appreciated. Input: strings with date and optional time. Different representations would be nice but necessary. The strings are user-supplied and can be malformed. Examples: - "2004-03-21 12:45:33" (I consider this the default layout) - "2004/03/21 12:45:33" (o...

How global fixtures work in BOOST.Test?

I have started using BOOST recently for unit testing. Just need one clarification on global fixtures. When it got executed? ... for each test module, or each test suite or each test case? Will it be the first before any thing else got executed? I am using the BOOST_AUTO_TEST_CASE for writing my tests. ...

What is the better way to generate test report in a file using BOOST.Test?

I know by default report is directed to standard-error, and so one has to redirect it to a file. My question is shall we do this inside a global fixture? Which isn't seem to be working for me some how. This is what i tried - struct MyConfig { MyConfig() : testReport("fileName.log") { if(!testReport.fail()) original = std...

Something like boost::multi_index for Python

Hi, I have come to appreciate a lot boost::multi_index in C++. It happens that I would happily use something like that in Python; for scripts that process data coming out from numerical intensive applications. Is there such a thing for Python? I just want to be sure that it doesn't exist, then I would try to implement it myself. Things ...