boost

Do you know of some performances test of the different ways to get thread local storage in C++?

I'm doing a library that makes extensive use of a thread local variable. Can you point to some benchmarks that test the performances of the different ways to get thread local variables in C++: C++0x thread_local variables compiler extension (Gcc __thread, ...) boost::threads_specific_ptr pthread Windows ... Does C++0x thread_local ...

How should I compile boost library in a small project?

I have a small project where I need just part of boost library, boost::regex in particular. This is what I've done so far: /include /boost /regex /math .. 189 dirs, files, etc. /lib /boost-regex c_regex_traits.cpp cpp_regex_traits.cpp .. ~20 .cpp files myprog.cpp In my Makefile I compile all boost-regex .cp...

Thread stuck in mutex wait while searching in Boost Interprocess managed_shared_memory

Hi All, We are using boost::interprocess::managed_shared_memory. Recently while testing we found that after process crash threads searching in shared memory got stuck in manage_shared_memory APIs. My initial observation is that m_header recursive lock which is member of segment_manager was in locked state while process crashed and res...

C++ member function template in derived class, how to call it from base class?

As my prveious question sounded confusing, I think it's best to clearly state what I want to achieve. I have (ignore the inheritance for now and focus on X): class Base {}; class X : public Base { private: double m_double; public: template<class A> friend void state( A& a, const X& x ) { data( a, x.m_double, "m_do...

Problem with boost::find_format_all, boost::regex_finder and custom regex formatter (bug boost 1.42)

I have a code that has been working for almost 4 years (since boost 1.33) and today I went from boost 1.36 to boost 1.42 and now I have a problem. I'm calling a custom formatter on a string to format parts of the string that match a REGEX. For instance, a string like: "abc;def:" will be changed to "abc\2Cdef\3B" if the REGEX contains "...

Boost.Thread throws bad_alloc exception in VS2010

Upon including <boost/thread.hpp> I get this exception: First-chance exception at 0x7c812afb in CSF.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::bad_alloc_> at memory location 0x0012fc3c.. First-chance exception at 0x7c812afb in CSF.exe: Microsoft C++ exception: [rethrow] at memory locati...

[C++] Boost test: catch user defined exceptions

If I have user defined exceptions in my code, I can't get Boost test to consider them as failures. For example, BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(MyTest,1) BOOST_AUTO_TEST_CASE(MyTest) { // code which throws user defined exception, not derived from std::exception. } I get a generic message: Caught exception: .... unknown locat...

Boost Mersenne Twister: how to seed with more than one value?

I'm using the boost mt19937 implementation for a simulation. The simulation needs to be reproducible, and that means storing and potentially reusing the RNG seeds later. I'm using the windows crypto api to generate the seed values because I need an external source for the seeds and not because of any particular guarantees of randomness...

Iterating through boost ptr_vector

Hello, I have a ptr_vector list of my own objects. Something like this: boost::ptr_vector<SomeClass> *list; list->push_back(new SomeClass()>; ... BOOST_FOREACH(SomeClass *tempObj, list) // [x] { tempObj->... } >‘boost::ptr_vector<SomeClass>*’ is not a class, struct, or union type ...

How to build boost foreach cycle

Hi guys! I have some abstract class called IClass (has pure virtual function). There are some classes which inherit IClass: CFirst, CSecond. I want to add objects of classes which inherit into boost::ptr_vector: class IClass { virtual void someFunc() = 0; }; class CFirst : public IClass { }; class CSecond : public IClass { }; boost::pt...

functional, bind1st and mem_fun

Why won't this compile? #include <functional> #include <boost/function.hpp> class A { A() { typedef boost::function<void ()> FunctionCall; FunctionCall f = std::bind1st(std::mem_fun(&A::process), this); } void process() {} }; Errors: In file included from /opt/local/include/gcc44/c++/bits/stl_func...

Where is shared_ptr?

I am so frustrated right now after several hours trying to find where shared_ptr is located. None of the examples I see show complete code to include the headers for shared_ptr (and working). Simply stating std, tr1 and <memory> is not helping at all! I have downloaded boosts and all but still it doesn't show up! Can someone help me by ...

Thread-safty of boost RNG

I have a loop which should be nicely pararellized by insering one openmp pragma: boost::normal_distribution<double> ddist(0, pow(retention, i - 1)); boost::variate_generator<gen &, BOOST_TYPEOF(ddist)> dgen(rng, ddist); // Diamond const std::uint_fast32_t dno = 1 <<...

Can I use boost library for crossplatform application executing?

Is there any WinAPI WinExec analog in boost (c++) libraries? I need to run executable from my program, and pass parameters to it. Should I use any other cross-platform libraries for this, or handle myself what OS my program is compiled for? ...

Confused about std::runtime_error vs. std::logic_error

I recently saw that the boost program_options library throws a logic_error if the command-line input was un-parsable. That challenged my assumptions about logic_error vs. runtime_error. I assumed that logic errors (logic_error and its derived classes) were problems that resulted from internal failures to adhere to program invariants,...

how a thread can signal when it's finished?

#include <iostream> #include <boost/thread.hpp> using std::endl; using std::cout; using namespace boost; mutex running_mutex; struct dostuff { volatile bool running; dostuff() : running(true) {} void operator()(int x) { cout << "dostuff beginning " << x << endl; this_thread::sleep(posix_time::seconds(2)...

boost::filesystem::path(std::wstring) throw exception

hi. this code: boost::filesystem::is_directory("/usr/include"); work fine. both this code: boost::filesystem::is_directory(L"/usr/include"); throw an exception: terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid OS - Linux Mint boost-1.43 gc...

Boost shared_ptr use_count function

My application problem is the following - I have a large structure foo. Because these are large and for memory management reasons, we do not wish to delete them when processing on the data is complete. We are storing them in std::vector<boost::shared_ptr<foo>>. My question is related to knowing when all processing is complete. Fir...

C++ member template for boost ptr_vector

Hi there, I'm trying to write a container class using boost::ptr_vector. Inside the ptr_vector I would like to include different classes. I'm trying to achieve that using static templates, but so far I'm not able to do that. For example, the container class is class model { private: boost::ptr_vector<elem_type> elements; public: vo...

Calling a method at a specific interval rate in C++

This is really annoying me as I have done it before, about a year ago and I cannot for the life of me remember what library it was. Basically, the problem is that I want to be able to call a method a certain number of times or for a certain period of time at a specified interval. One example would be I would like to call a method "x" s...