boost

Is boost tuple mutable?

I have been using a using a boost tuple as the value in an STL map. Up until now, I only had to construct the tuple and insert into the map and at a later stage retrieve the values. Now I need to be able to change the tuple in the map. Is this possible, or have I run into the one place you should'nt be using tuples instead of structs. ...

Boost Property Tree with filename as key

I am trying to use filenames as the key in boost::PropertyTree However, the '.' character in a filename such as "example.txt" causes an additional layer to be added within the property tree. The most obvious solution would be to replace '.' with another character, but there is likely a better way to do this, such as with an escape char...

How can I add an item to two queues and guarantee that it exists in both or none (multi-threaded)

I have the following problem. I have two classes, in this case A and B, which both own a concurrent_queue. The assumption here is that concurrent_queue is a thread-safe queue, with a blocking push() function. When an object is enqueued in B, it accesses the singleton A and it is queued up in A as well. This has the effect that a whole b...

Removing a single pointer from a boost::ptr_list list?

If I create a bunch of elements in a boost::ptr_list container how can I remove individual pointers from it? Say I do this: boost::ptr_list intlist; int *i = new int(3); intlist.Add(i); int *i2 = new int(1); intlist.Add(i2); int *i3 = new int(6); intlist.Add(i3); How can I remove say i3 and not i or i2 from the list? ...

istream from file_descriptor_source (boost::iostreams) or file

I need to do something like this for my program's input: stream input; if (decompressed) input.open(filepath); else { file_descriptor=_popen("decompressor "+filepath,"r"); input.open(file_descriptor); } input.read(...) ... I can see 1 solution... to use _popen in both cases and just copy the file to stdout if it's already ...

Is it OK to use boost::shared ptr in DLL interface?

Is it valid to develop a DLL in C++ that returns boost shared pointers and uses them as parameters? So, is it ok to export functions like this? 1.) boost::shared_ptr<Connection> startConnection(); 2.) void sendToConnection(boost::shared_ptr<Connection> conn, byte* data, int len); In special: Does the reference count work across DLL b...

how to cache a lambda in c++0x ?

Hello, I'm trying to work with lambda's in C++ after having used them a great deal in C#. I currently have a boost tuple (this is the really simplified version). typedef shared_ptr<Foo> (*StringFooCreator)(std::string, int, bool) typedef tuple<StringFooCreator> FooTuple I then load a function in the global namespace into my FooTuple...

Boost Filesystem createdirectories on Linux replacing "/" with "\"

When using Boost Filesystem's createdirectory (and createdirectories) function in the following example, "/" is being replaced with "\". boost::filesystem::path path ("/data/configSet"); boost::filesystem::create_directory(path); This code snipped produces a directory called "data\configSet", instead of creating a subdirectory of "con...

CMake finds boost but nmake fails to link

...

Displaying exception debug information to users

Hi, I'm currently working on adding exceptions and exception handling to my OSS application. Exceptions have been the general idea from the start, but I wanted to find a good exception framework and in all honesty, understand C++ exception handling conventions and idioms a bit better before starting to use them. I have a lot of experien...

initialize boost array/multi_array

Hi, i defined boost::multi_array with typedef boost::multi_array<unsigned int, 1> uint_1d_vec_t; typedef boost::multi_array<unsigned int, 2> uint_2d_vec_t; uint_1d_vec_t foo( boost::extents[ num_elements ] ); uint_2d_vec_t boo( boost::extents[ num_elements/2 ][ kappa ] ); were num_elements/2 ist an integer number...

C++ range/xrange equivalent in STL or boost?

hello Is there C++ equivalent for python Xrange generator in either STL or boost? xrange basically generates incremented number with each call to ++ operator. the constructor is like this: xrange(first, last, increment) was hoping to do something like this using boost for each: foreach(int i, xrange(N)) I. am aware of the for loo...

changing value in a stl map in place.

I understand that when we insert values into the STL map, a copy is made and stored. I have code that essentially does a find on the map and obtains an iterator. I then intend to use the iterator to change the value in the map. The results are not what I would expect ie: the value is not changed when accessed from another part of the pr...

BOOST_STATIC_ASSERT without boost

Since boost is forbidden in a company I work for I need to implement its functionality in pure C++. I've looked into boost sources but they seem to be too complex to understand, at least for me. I know there is something called static_assert() in the C++0x standart, but I'd like not to use any C++0x features. ...

How can I use boost::mpl::fold with a boost::fusion::map?

Hi. When I try to compile this: #include <boost/fusion/container/map.hpp> #include <boost/mpl/fold.hpp> int main(int argc, char** argv) { typedef boost::fusion::map < boost::fusion::pair<int, const char*>, boost::fusion::pair<long, char> > FuMap; FuMap fuMap("hello", 'w'); unsigned val = boost::mpl...

boost asio io_service.run() question

I was just going over the asio example here: http://www.boost.org/doc/libs/1%5F39%5F0/doc/html/boost%5Fasio/example/chat/chat%5Fserver.cpp My question is about their usage of the io_serice.run() function. The documentation for the io_service.run() function says: "The run() function blocks until all work has finished and there are no mo...

Problem in setting up boost library on ubuntu

Hi, I have compiled and installed my boost library in '/media/data/bin' in ubuntu 9.10. And I have setup the INCLUDE_PATH, LIBRARY_PATH env: $ echo $INCLUDE_PATH /media/data/bin/boost/include: $ echo $LIBRARY_PATH /media/data/bin/boost/lib: But when I compile the asio example, I get the following error: $ g++ blocking_tcp_echo_server...

Operator overloading for a class containing boost::numeric::ublas::matrix<double>

I have a class which contains a few boost::numeric::ublas::matrix's within it. I would like to overload the class's operators (+-*/=) so that I can act on the set of matrices with one statement. However this seems to require temporary instances of my class to carry values around without modifying the original class. This makes sense...

boost::mpl for_each with normal 'C' Array.

Using boost::mpl, I can create a typedef of a three element vector like follows: typedef boost::mpl::vector_c<int,1,2,3> height_t; I can pull the values out of this typedef with the following snippit: std::vector<int> height; boost::mpl::for_each<height_t>(boost::bind(&std::vector<int>::push_back, &height, _1)); assert(height[0] ...

boost::function run-time performance

I'm in the process of implementing a platform independent wrapper for dynamically loaded libraries. Of course when I load functions from the libraries I need to store them as pointers for future use. I thought of using boost::function's for that instead of normal function pointers. Sure, that will increase compile time, but that's not wh...