boost

C++: how to use std::less<int> with boost::bind and boost::lambda?

I am trying to lean boost::bind, boost::lambda libraries and how they can be used with STL algorithms. Suppose I have vector of int-string pairs which is sorted by int key. Then a place to insert a new pair while keeping the vector sorted can be found as follows: std::vector<std::pair<int, string> > entries; ... int k = ...; // Let's i...

Looping over the non-zero elements of a uBlas sparse matrix.

I have the following sparse matrix that contains O(N) elements boost::numeric::ublas::compressed_matrix<int> adjacency (N, N); I could write a brute force double loop to go over all the entries in O(N^2) time like below, but this is going to be too slow. for(int i=0; i<N; ++i) for(int j=0; j<N; ++j) std::cout << adjacency(...

Problem installing Shoutpy + Boost.python on opensolaris

Hi all, Im trying to install shoutpy on opensolaris 2009.6. It relies on boost.python. i've installed the boost_devel libraries from blastwave and linked /opt/csw/include/boost to /usr/include/boost . But when I try to easy_install shoutpy I get the following output munderwo@opensolaris-test1:/usr/include$ pfexec easy_install shoutpy S...

Anyone uses boost::multiindex as a one-table database?

I need to maintain a 200 entries, 12 column table at extremely high speed, can I simply use boost multiindex to cutoff the sql overhead? Has anyone ever tried to do this? What are the cons and pros of such a solution? thanks ...

Modifying contents of vector in BOOST_FOREACH

This is a question that goes to how BOOST_FOREACH checks it's loop termination cout << "Testing BOOST_FOREACH" << endl; vector<int> numbers; numbers.reserve(8); numbers.push_back(1); numbers.push_back(2); numbers.push_back(3); cout << "capacity = " << numbers.capacity() << endl; BOOST_FOREACH(int elem, numbers) { cout << elem << end...

Selection between ACE & Boost for learning

Hi everyone, I am an intermediate c++ programmer and done some work using ACE, now I want to learn one of those Libraries thoroughly to progress in to my career. That why I need your kind help to make a decision, that what should I learn first. And also please consider my destinations are to be an expert network programmer and Protocol d...

How to accept empty value in boost::program_options

I'm using boost::program_options library to process command line params. I need to accept a file name via -r option, in case if it is empty (-r given without params) I need to use stdin. desc.add_options() ("replay,r", boost::program_options::value<std::string>(), "bla bla bla") In this case boost wouldn't accept -r without params an...

file search in c++

hey I just started learning c++ and am currently using codeblocks. i wanna write an application that can search for files in directory including it's subdirs, but i cant seem to find any good examples for this and i've read somewhere that this is only possible trough a library like boost. is this true? any examples for doing it withou...

Boost lib linker error Visual C++

I downloaded the source for Launchy and am trying to build it in Visual Studio 2005. The Launchy project is built using VC7 so I had to update the project files to VC8 and that process seemed to go well. However, Launchy also uses the Boost 1.33.1 libs and what I have built are the Boost 1.41.0 libs (props to Boost for making the more ...

C++ serialization library that supports partial serialization?

Are there any good existing C++ serialization libraries that support partial serialization? By partial serialization I mean that I might want to say, save the values of 3 specific members, and later be able to apply that saved copy to a different instance, only updating those 3 members and leaving the others intact. This would be useful ...

boost::system::(...)_category defined but not used

I'm currently getting compiler warnings that resemble the warning I gave in the question title. Warnings such as.... warning: 'boost::system::generic_category' defined but not used warning: 'boost::system::posix_category' defined but not used warning: 'boost::system::errno_ecat' defined but not used warning: 'boost::system::native_ec...

Problem with iterators for std::list of boost::shared_ptr

Hi, I'm having a problem with the following code: #include <list> #include <boost/shared_ptr.hpp> #include "Protocol/IMessage.hpp" template <typename HeaderType> class Connection { public: typedef IMessage<HeaderType> MessageType; typedef boost::shared_ptr<MessageType> MessagePointer; template <typename Handler>...

Sun C++ Compilers and Boost

I am currently developing on OpenSolaris 2009-06. The Boost::MPL Documentation seems to suggest that sun compilers are not supported (the document was last updated in 2004 ). Boost's top level documentation seems to suggest that the sun compilers 5.10 onwards are supported -- I guess this is a general level of support or does this includ...

search for multiple indecies with Boost Multi-Index

Hi, how do I limit the search in a boost::multi_index by the result of a previous search? As an example: suppose I have a rectangle class with an internal value like this: class MyRect { public: int width; int height; double value; } and I need a data structure of such object to answ...

Usage of boost lambdas

I am new to boost and trying to write some simple programs to understand it. Here in the following piece of code I am trying to fill an array with random numbers. Here is my code: using namespace boost::lambda; srand(time(NULL)); boost::array<int,100> a; std::for_each(a.begin(), a.end(), _1=rand()); But it looks like r...

C++ character replace

What is the best way to replace characters in a string? Specifically: "This,Is A|Test" ----> "This_Is_A_Test" I want to replace all commas, spaces, and "|" with underscores. (I have access to Boost.) ...

C++ swap problem in inheritance scenario

I want to add swap functionality to two existing C++ classes. One class inherits from the other. I want each classes' instances to only be swappable with instances of the same class. To make it semi-concrete, say I have classes Foo and Bar. Bar inherits from Foo. I define Foo::swap(Foo&) and Bar::swap(Bar&). Bar::swap delegates to ...

Boost: what could be the reasons for a crash in boost::slot<>::~slot ?

I am getting such a crash: #0 0x90b05955 in __gnu_debug::_Safe_iterator_base::_M_detach #1 0x90b059ce in __gnu_debug::_Safe_iterator_base::_M_attach #2 0x90b05afa in __gnu_debug::_Safe_sequence_base::_M_detach_all #3 0x000bc54f in __gnu_debug::_Safe_sequence_base::~_Safe_sequence_base at safe_base.h:170 #4 0x000aac05 in __gnu_debug...

Boost: what exactly is not threadsafe in Boost.Signals ?

I read at multiple places that Boost.Signals is not threadsafe but I haven't found much more details about it. This simple quote doesn't say really that much. Most applications nowadays have threads - even if they try to be single threaded, some of their libraries may use threads (for example libsdl). I guess the implementation doesn't ...

How to avoid memory leak with boost::shared_ptr?

Consider the following code. using boost::shared_ptr; struct B; struct A{ ~A() { std::cout << "~A" << std::endl; } shared_ptr<B> b; }; struct B { ~B() { std::cout << "~B" << std::endl; } shared_ptr<A> a; }; void main() { shared_ptr<A> a (new A); shared_ptr<B> b (new B); a->b = b; b->a = a; } There is ...