boost

compile Boost as static Universal binary lib

I want to have a static Universal binary lib of Boost. (Preferable the latest stable version, that is 1.43.0, or newer.) I found many Google hits with similar problems and possible solutions. However, most of them seems outdated. Also none of them really worked. Right now, I am trying sudo ./bjam --toolset=darwin --link=static --threa...

upgrading boost version

I'm using RHEL 5.3, shipped with gcc 4.1.2 and boost 1.33. So, there's no boost::unorded_map, no make_shared() factory function to create boost::shared_ptr and other features available in newer releases of boost. Is there're a newer version of boost compatible with the version of gcc? If yes, how the upgrade is performed? ...

What is the difference between default_value and implicit_value in boost::program_options?

That's the question. Why would I use implicit_value over default_value and vice versa? Thanks! ...

Boost thread synchronization in release build

Hi, when I try to run the following code in debug and release mode in VS2005. Each time I see different output in console and It doesn't seem like the multithreading is achieved in release mode. 1. #include <boost/thread.hpp> 2. #include <iostream> 3. 4. void wait(int seconds) 5. { 6. boost::this_thread::sleep(boost::posix_time::s...

boost multi_index_container and erase performance

I have a boost multi_index_container declared as below which is indexed by hash_unique id(unsigned long) and hash_non_unique transaction id(long). Insertion and retrieval of elements is fast but when I delete elements, it is much slower. I was expecting it to be constant time as key is hashed. e.g To erase elements from container for 1...

Using boost::asio::async_read with stdin?

hi poeple.. short question: I have a realtime-simulation which is running as a backround process and is connected with pipes to the calling pogramm. I want to send commands to that process using stdin to get certain information from it via stdout. Now because it is a real-time process, it has to be a non blocking input. Is boost::asio::a...

Using mem_fun_ref with boost::shared_ptr

Following the advice of this page, I'm trying to get shared_ptr to call IUnknown::Release() instead of delete: IDirectDrawSurface* dds; ... //Allocate dds return shared_ptr<IDirectDrawSurface>(dds, mem_fun_ref(&IUnknown::Release)); error C2784: 'std::const_mem_fun1_ref_t<_Result,_Ty,_Arg> std::mem_fun_ref(Result (_thiscall _Ty::* )...

Problem with basic program using Boost Threads in c++

I have a simple program which creates and executes as thread using boost threads in c++. #include<boost/thread/thread.hpp> #include<iostream> void hello() { std::cout<<"Hello, i am a thread"<<std::endl; } int main() { boost::thread th1(&hello); th1.join(); } The compiler throws an error against the th1.join() line....

Use boost date_time to parse and create HTTP-dates

I'm writing a kind of HTTP proxy, so I need to be able to do 3 things: Parse an HTTP-date given any of the 3 formats specified in RFC 2616, sec 3.3, Convert a file date-time to an HTTP-date string, and Output the date to a string. For reference, theses are examples of the date-times I need to parse. I will output only the first form...

why my C++ output executable is so big?

I have a rather simple C++ project, which uses boost::regex library. The output I'm getting is 3.5Mb in size. As I understand I'm statically linking all boost .CPP files, including all functions/methods. Maybe it's possible somehow to instruct my linker to use only necessary elements from boost, not all of them? Thanks. $ c++ —version i...

How to loop through a boost::mpl::list?

This is as far as I've gotten, #include <boost/mpl/list.hpp> #include <algorithm> namespace mpl = boost::mpl; class RunAround {}; class HopUpAndDown {}; class Sleep {}; template<typename Instructions> int doThis(); template<> int doThis<RunAround>() { /* run run run.. */ return 3; } template<> int doThis<HopUpAndDown>() { /* hop ho...

What is the proper use of boost::fusion::push_back?

// ... snipped includes for iostream and fusion ... namespace fusion = boost::fusion; class Base { protected: int x; public: Base() : x(0) {} void chug() { x++; cout << "I'm a base.. x is now " << x << endl; } }; class Alpha : public Base { public: void chug() { x += 2; cout << "Hi, I'm an ...

Function Composition in C++

There are a lot of impressive Boost libraries such as Boost.Lambda or Boost.Phoenix which go a long way towards making C++ into a truly functional language. But is there a straightforward way to create a composite function from any 2 or more arbitrary functions or functors? If I have: int f(int x) and int g(int x), I want to do someth...

Boost multi_index ordered_unique Median Value

I would like to quickly retrieve the median value from a boost multi_index container with an ordered_unique index, however the index iterators aren't random access (I don't understand why they can't be, though this is consistent with std::set...). Is there a faster/neater way to do this other than incrementing an iterator container.size...

How to use boost::fusion::transform on heterogeneous containers?

Boost.org's example given for fusion::transform is as follows: struct triple { typedef int result_type; int operator()(int t) const { return t * 3; }; }; // ... assert(transform(make_vector(1,2,3), triple()) == make_vector(3,6,9)); Yet I'm not "getting it." The vector in their example contains elements all of...

Boost ForEach Question

Trying to use something like the below with a char array but it doesn't compile. But the example with short[] works fine. Any idea why? :) char someChars[] = {'s','h','e','r','r','y'}; BOOST_FOREACH(char& currentChar, someChars) { } short array_short[] = { 1, 2, 3 }; BOOST_FOREACH( short & i, array_short ) { ...

How to connect/disconnect from a server?

I am using the latest version of boost and boost.asio. I have this class: enum IPVersion { IPv4, IPv6 }; template <IPVersion version = IPv4> class Connection { private: boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver; boost::asio::ip::tcp::resolver::query query; boost::asio::ip::tcp...

boost::regex_replace() replaces only first occurrence, why?

My code: #include <string> #include <boost/algorithm/string/regex.hpp> std::cout << boost::algorithm::replace_regex_copy( "{x}{y}", // source string boost::regex("\\{.*?\\}"), // what to find std::string("{...}") // what to replace to ); This is what I see: {…}{y} Thus, only the first occurrence replaced. Why? How to so...

how to find all occurrences in REGEX with

My code is: #include <boost/regex.hpp> boost::cmatch matches; boost::regex_match("alpha beta", matches, boost::regex("([a-z])+")); cout << "found: " << matches.size() << endl; And it shows found: 2 which means that only ONE occurrence is found… How to instruct it to find THREE occurrences? Thanks! ...

Can I get a raw pointer from boost's weak_ptr?

Is it possible to get a raw pointer from boost::weak_ptr? Boost's shared_ptr has get() method and "->" operator. Is there some rationale behind weak_ptr not having the same functionality? ...