boost

boost.asio. The possibility to expect the completion of any object in queue is necessary.

In asio:: io_service I insert objects. asio:: io_service::run() runs in several threads. The possibility to expect the completion of any object in queue is necessary. For example: template <typename T> struct handler { void operator()() { .... } T get() const {...} }; asio::io_service ios; ios.post(handler()); How I c...

My first encounter with Boost... Include errors

I am trying to run a boost example but I am getting the following error: g++ bimap.cpp -o bimap bimap.cpp:1:28: error: boost/config.hpp: No such file or directory bimap.cpp:8:27: error: boost/bimap.hpp: No such file or directory bimap.cpp: In function 'int main()': bimap.cpp:27: error: 'boost' has not been declared bimap.cpp:27: error: ...

memory fences/barriers in C++: does boost or other libraries have them?

I am reading these days about memory fences and barriers as a way to synchronize multithreaded code and avoid code reordering. I usually develop in C++ under Linux OS and I use boost libs massively but I am not able to find any class related to it. Do you know if memory barrier of fences are present in boost or if there is a way to ach...

value_type size

is there any ways of retrieving the number of elements in typename X::value_type where X is a vec of tuples? thanks ...

Singletons destructors

Hello, I'm using boost's singletons (boost::serialization::singleton). I have to control the queue of class destructings. One singleton consist of the object whicn uses object from second singleton. And I have to delete second singleton, before the first one. Can I do this? p.s. please, don't say anything about singleton programming tec...

String operations in Jamfiles

How can I make a Jamfile path-independent ? As in local headers = [ path.glob-tree /home/morpheus/base : *.hpp ] ; install headers : $(headers) : <location>/home/morpheus/base_install <install-source-root>$(TOP) ; project basetrade : requirements <include>/home/morpheus/base_install <variant>release:<cxxflags>-O...

Parsing positional arguments

Consider the following trivial program adopted from the boost program options examples #include <boost/program_options.hpp> #include <boost/version.hpp> #include <iostream> int main( int argc, char** argv ) { namespace po = boost::program_options; po::options_description desc("Options"); unsigned foo; desc.add_option...

Boost shared_from_this() returning wrong shared_ptr

I'm trying to use boost::shared_ptr and boost::enable_shared_from_this to no avail. It looks as if shared_from_this() is returning the wrong shared_ptr. Here is what I see: Task* task = new TaskSubClass(); boost::shared_ptr<Task> first = boost::shared_ptr<Task>(task); // use_count = 1, weak_count = 1 boost::shared_ptr<Task> second = fir...

Iterate over items in Boost Property Tree

I'm using boost property tree to store configuration data for my application. In the configuration file I have an item named that looks like this. I'm wondering how I can iterate over the ServerList. ServerList { server1 127.0.0.1:5000 server2 example.com } By the way the solution provided here, didn't seem to work for me: http...

Boost serialization multiple objects

Hi all, Im trying to build a persistence module and Im thinking in serialize/deserialize the class that I need to make persistence to a file. Is possible with Boost serialization to write multiple objects into the same file? how can I read or loop through entrys in the file? Google protocol buffers could be better for me if a good perf...

shared_ptr puzzle

Hi, I'm using ACE framework, but I'll try to describe my problem without referencing to it. I have an event handler (class derived from ACE_Event_Handler). Reference to the event handler is hold by some manager class in maps of shared_ptr's. At some point of time I want to: remove the event handler from manager map Some method of ev...

boost unique_ptr Deletor

If I want to create a unique_ptr of type QueueList (some self defined object), how do I define a deletor for it or is there already a template 'Deletor' I can use? I want a unique_ptr so I can safely transfer the object between threads, without sharing it between the threads. EDIT boost::interprocess::unique_ptr<QueueList> LIST; ///F...

boost example failed to build

Hello, I'm a newbie about boost. I compiled boost libraries with success (under mac os x). Now, I tried to build the very first example mentioned at boost website (including boost/ as include directory and boost/stage/lib as library directory, with netbeans) and got the following error "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAK...

Finding sorted middle 50% of a sequence (in Boost Accumulators or in other data structure)

For a sequence of values, how would one find the sorted middle 50% of the sequence in Boost Accumulators? For example, let's say that I have the following sequence, 25, 21, 9, 13, 17, 19, 12, 29, 50, 97, 10, 11. The middle 50% data I would like to have is as follows: 13, 17, 19, 21. Of course, one can sort the sequence, which now beco...

List of boost::Unique_Ptr objects

Why can I not do this? typedef boost::interprocess::unique_ptr<QueueList, QueueListDeletor> UQList; typedef boost::intrusive::list<UQList> List; // Compiler (VS 2003) complains The QueueList is a class that derives from public boost::intrusive::list_base_hook<> to make it part of an intrusive linked list. I want to use unique_ptr ...

Mixing variables and integer constants in the Boost Preprocessor

I am using BOOST_PP for to do precompile computations in the preprocessor. I am focusing on an application where code size is extremely important to me. (So please don't say the compiler should or usually does that, I need to control what is performed at compile time and what code is generated). However, I want to be able to use the same...

boost::numeric::ublas::vector<double> and double[]

I'm using boost for matrix and vector operations in a code and one of the libraries I am using (CGNS) has an array as an argument. How do I copy the vector into double[] in a boost 'way', or better yet, can I pass the data without creating a copy? I'm a bit new to c++ and am just getting going with boost. Is there a guide I should rea...

C++ shader question

Hello! Does somebody know where I can find a sample of shader (HLSL / CG / GLSL / Backend-independent) class? Of course, standard API (like D3DXEffect or same in GL) exists, but it's kind of ugly and not what I'm looking for. I'm looking for a high-quality interface design, not "just yet another implementation sample". Ideally someth...

C++: ptr_container comparison

How can I customize the comparison of elements in a ptr_container? Using a ptr_set, I would like to define a function that checks for equality of elements. However, defining bool operator==(const Foo& other) (or a friend function) does not work. It just won't be invoked, although boost's unordered containers, on the other side, are aw...

C++ replace multiple strings in a string in a single pass

Hi, Newbie here. Given the following string, "Hi ~+ and ^*. Is ^* still flying around ~+?" I want to replace all occurrences of "~+" and "^*" with "Bobby" and "Danny", so the string becomes: "Hi Bobby and Danny. Is Danny still flying around Bobby?" I would prefer not to have to call Boost replace function twice to replace the occurr...