boost

Build Boost-powered solution in VS

Boost rocks, it is great and extremely powerful, but I hate it everytime I build solution in my Visual Studio 7.1. It seems Boost has impact on build time (not positive). I cannot remove all Boost usage from my project to compare build times but I tried it on small projects and the difference is meaningful. I guess the problem is tha...

Better seeds than time(0)?

I understand that time(0) is commonly using for seeding random number generators and that it only becomes a problem when the program is being run more than once per second. I'm wondering what are some better seeds to consider when generating random numbers. I read about GetTickCount, timeGetTime, and QueryPerformanceCounter on Windows. W...

Boost - cross compile - "from Linux" "to Windows"

Hello, I have downloaded "boost" (1.40.0) source code from their homepage "www.boost.org". I have Linux (Ubuntu 9.04 Jaunty) installed and trying to compile the boost libraries to the "WINDOWS" version (e.g. ".dll", NOT ".so") from my "LINUX" machine. And now an important question: IS IT POSSIBLE TO COMPILE TO THE "WINDOWS" BOOST LIBR...

shared_ptr and references in C++

References in C++ are a conveneint construct that allow us to simplify the following C code: f(object *p){ //do something } int main(){ object* p = (object*) calloc(sizeof(object)); f(p); } to f(object& o){ //do something } int main(){ object o = object(); f(o); } Shared pointers are another convenience in C++ that s...

What is boost's shared_ptr(shared_ptr<Y> const & r, T * p) used for?

boost::shared_ptr has an unusual constructor template<class Y> shared_ptr(shared_ptr<Y> const & r, T * p); and I am a little puzzled as to what this would be useful for. Basically it shares ownership with r, but .get() will return p. not r.get()! This means you can do something like this: int main() { boost::shared_ptr<int> x(ne...

Using STL/Boost to find and modify matching elements in a vector

Let's say I have a vector declared like this: struct MYSTRUCT { float a; float b; }; std::vector<MYSTRUCT> v; Now, I want to find all elements of v that share the same a, and average their b, i.e. Say v contains these five elements {a, b}: {1, 1}, {1, 2}, {2, 1}, {1, 3}, {2, 2} I want to get v[0], v[1], v[3] (where a is 1) and av...

Problem Linking Boost Library in Linux

I am trying to build a project using Boost's Asio and I am having some trouble. Initially, I tried to build the project without any additional libraries since everything is supposedly in the header files. The program I am trying to build looks like this: #include <iostream> #include <boost/asio.hpp> #include <boost/date_time/posix_tim...

Returning a c++ array (pointer) from boost python

I'm currently writing python bindings for a c++ library I'm working on. The library reads some binary file format and reading speed is very important. While optimizing the library for speed, I noticed that std::vector (used in the instances I'm reading) was eating up a lot of processing time, so I replaced those with simple arrays alloca...

waiting for multiple condition variables in boost?

I'm looking for a way to wait for multiple condition variables. ie. something like: boost::condition_variable cond1; boost::condition_variable cond2; void wait_for_data_to_process() { boost::unique_lock<boost::mutex> lock(mut); wait_any(lock, cond1, cond2); //boost only provides cond1.wait(lock); process_data(); } ...

Using boost::shared_ptr within inheritance hierarchy

Imagine the following situation: class IAlarm : public boost::enable_shared_from_this<IAlarm> { boost::shared_ptr<IAlarm> getThisPointerForIAlarm() { return shared_from_this(); } void verifyThis(int); // called by Device }; class Alarm : public IAlarm { Alarm( boost::shared_ptr< Device > attachedDevice){ att...

Distributing with Boost Library?

Hey guys, i'm quite new to using boost and I can't seem to find documentation anywhere on how to distribute your application when using boost? Many of the libraries are shared libraries, i'm not expecting my users to have boost installed, i'm only using a single library (regex) so is there an easy way to package the regex library with m...

Boost Jam Not Producing Thread Library on Windows

I downloaded the latest Boost Jam binary from SourceForge and I'm using the command: bjam toolset=gcc --build-type=complete stage I've installed Cygwin along with the GCC compiler. While the command produces a stage/lib directory, I cannot find the thread library that I'm using in Linux. Boost Jam takes a while to run, so there coul...

How does boost implements signals and slots?

To continue another question, lets ask this: How does Boost implement the signals/slot mechanism? See: http://stackoverflow.com/questions/1406940/how-signal-and-slots-are-implemented-under-the-hood http://www.boost.org/doc/libs/1%5F40%5F0/doc/html/signals.html ...

Get year from boost ptime

Hi, This is my first post on stackoverflow. First of all I'd like to say thanks for this site! It has provided many excellent answers to questions I've had in the past few months. I'm still learning C++, coming from vb6. I'm converting an existing program to C++ and here need to manipulate Sybase timestamps. These timestamps contain dat...

In the Visual Studio debugger, what does {null=???} mean?

I was debugging a C++ program in VS 2003, and a boost variable showed up as having the value {null=???}. What does that mean? ...

Boost Library, how to get determinant from lu_factorize()?

I am trying to calculate a determinant using the boost c++ libraries. I found the code for the function InvertMatrix() which I have copied below. Every time I calculate this inverse, I want the determinant as well. I have a good idea how to calculate, by multiplying down the diagonal of the U matrix from the LU decomposition. There i...

Need help allocating space for vector within class definition using boost.

I am trying to allocate space for a boost vector type in a class definition. I am not a good c++ programmer, but shown below is my best attempt. There are no error messages, but when I try to access the vector from my main function it believes that the vector has zero elements. I know this is because I did not tell the compiler how mu...

Boost - "static" vs "shared" libraries

Hello, I am building "boost" libraries from boost source code and I have two options: to build it "static" or to build it "shared" (e.g. dynamic). Which is better idea? I prefer dynamic (shared) linking but when I tried to build boost shared libraries (on Ubuntu Linux), I got lots of errors or warnings (why there are always errors, warn...

Perform a simple HTTP request using C++ / Boost via a proxy?

I'm quite a newbie with Boost, and my only experience of surfing though a proxy using a library is using .NET (that is really convenient for that purpose). I'm now trying to perform a simple HTTP request through a HTTP proxy. Is there a tidy way to do it using boost directly? My proxy use a NTLM authentification. ...

Creating dummy shared object (.so) to depend on other shared objects

I'm trying to create a shared object (.so) that will make it so, by including one shared object with -lboost, I implicitly include all the boost libraries. Here's what I tried: #!/bin/sh BOOST_LIBS="-lboost_date_time-gcc43-mt -lboost_filesystem-gcc43-mt" #truncated for brevity g++ $BOOST_LIBS -shared -Wl,-soname,libboost.so.1 -o libb...