boost

Derived class stored in ptr_vector not being destructed

Was trying to find the best way to use ptr_vector to store, access and release objects, especially when the stored object is inherited from other (ptr_vector should not have any issues with object slicing). But when running the below program, surprisingly the derived class isn't being destructed. Anyone know why? #include <boost/ptr_con...

What’s the best way to delete boost::thread object right after its work is complete?

I create boost::thread object with a new operator and continue without waiting this thread to finish its work: void do_work() { // perform some i/o work } boost::thread *thread = new boost::thread(&do_work); I guess, it’s necessary to delete thread when the work is done. What’s the best way to this without explicitly waiting for ...

How to use C++ Boost library with pkg-config?

I successfully compiled and installed the latest version of the Boost library onto my linux machine. Now, I would like to be able to use pkg-config to ease the process of providing linking paremeters with GCC. Since I am too lazy for hand-coding my own .pc file, is there a script/tool which would automatically generate the needed .pc fi...

C++ event processing

Hello. I am using the excellent asio for an asynchronous network client. When handling read (async_read) I am concerned that the method/function handling the data might hang or take too long (the function is supplied by the user of the class). What is the best way of calling the supplied function and ensuring it won't take too long ? ...

Trouble linking boost libaries in Visial Studio 2010.

I compiled my boost libaries according to the guide found here and tried to use the boost filesystem libary. When I add #include <boost\filesystem\operations.hpp> I get the following errors: error LNK2028: unresolved token (0A00009A) "class boost::system::error_code __clrcall boost::filesystem2::detail::dir_itr_close(void * &)" (?dir...

build boost library

i have boost librray 1.44.0 how can i build it?i am using visual studio 2010 thanks ...

Boost preprocessor: Sample not working

Hi all, I tried to compile a sample from the Boost.Preprocessor library which is: #include <boost/preprocessor/seq/insert.hpp> #define SEQ (a)(b)(d) BOOST_PP_SEQ_INSERT(SEQ, 2, c) // expands to (a)(b)(c)(d) on Visual Studio 2008 and I get the error error C2065: 'b' : undeclared identifier Is there a problem with the sample or am I m...

Passing a boost::unordered_set as the result map to boost::split

Does anyone know if it's kosher to pass a boost::unordered_set as the first parameter to boost::split? Under libboost1.42-dev, this seems to cause problems. Here's a small example program that causes the problem, call it test-split.cc: #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/split.hpp> #in...

C++ boost how to get a number of members in enum?

is there anything in the boost which could help to get a number of members in enumeration? e.g. to return 3 for the following code: enum SomeEnum { One, Two, Three } ...

Boost 1.44.0 + VS2010 Private member error

I have a class declaration in Utils.h: class Utils { private: static boost::mutex outputMutex; }; In the cpp file: boost::mutex Utils::outputMutex = boost::mutex(); I get: Error 1 error C2248: 'boost::mutex::mutex' : cannot access private member declared in class 'boost::mutex' If we look inside boost/thread/win32/...

how to use boost::unordered_map

hello, for my application, i need to use a hash map, so i have written a test program in which i store some instances of a baseclass in a boost::unordered_map. but i want to reach the instances by calling special functions which return a derived class of the base and i use those functions' parameters for hash key of unordered_map. if no...

cannot convert from 'boost::interprocess::mapped_region' to 'boost::interprocess::mapped_region &&'

When I try to compile a simple boost application with #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/managed_shared_memory.hpp> headers in VS 2010, I get the this error message. c:\program files\boost\boost_1_44_0\boost\interprocess\detail\move.hpp(342): error C2440: 'return' : cannot convert fro...

boost::regex_search - boost kills my brain cells, again

Good programmers keep simple things easy right? And it's not like the boost documentation makes your life less uneasy... All I want is an implementation for: // fulfils the function of a regex matching where the pattern may match a // substring instead of the entire string bool search( std::string, std::string, SomeResultType ) So it...

C++ Thread Pool

What is a good open source implementation of a thread pool for C++ to use in production code (something like boost)? Please provide either your own example code or a link to example code usage. ...

UMFPACK and BOOST's uBLAS Sparse Matrix

I am using Boost's uBLAS in a numerical code and have a 'heavy' solver in place: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?LU_Matrix_Inversion The code works excellently, however, it is painfully slow. After some research, I found UMFPACK, which is a sparse matrix solver (among other things). My code generates la...

boost::dynamic_pointer_cast returning null on valid cast

I'm using boost::shared_ptr's and boost::dynamic_pointer_cast. I have a base class, an interface that inherits from that base class, and then a class that inherits from that one. So A -> B -> C. I create an object of type C and it's stored as a shared_ptr of type A. Then I try and do a dynamic_pointer_cast to type B, but boost::dynamic_...

What are the security implications of using boost/format?

I am starting to use boost/format. When coding with boost/format, what should I pay attention to with regard to security? Can I do the following without being concerned about security? std::cout << boost::format("Hello %2%! Do you want to %1%?") % user_supplied_str1 % user_supplied_str2 << std::endl; What are situations where ...

C++ - boost get question

Hello! Does someone know if the boost::get for the boost::variant is a performance-consuming operation or not. Right now I am refactoring some old code in a performance-critical part, where "varianting" was implementing by containers for each possible types and corresponding enum. Obviously, this is fast, but ugly and right now when I...

boost::shared_array and aligned memory allocation

In Visual C++, I'm trying to dynamically allocate some memory which is 16-byte aligned so I can use SSE2 functions that require memory alignment. Right now this is how I allocate the memory: boost::shared_array aData(new unsigned char[GetSomeSizeToAllocate()]); I know I can use _aligned_malloc to allocate aligned memory, but will th...

How to compare vectors with Boost.Test?

I am using Boost Test to unit test some C++ code. I have a vector of values that I need to compare with expected results, but I don't want to manually check the values in a loop: BOOST_REQUIRE_EQUAL(values.size(), expected.size()); for( int i = 0; i < size; ++i ) { BOOST_CHECK_EQUAL(values[i], expected[i]); } The main problem is...