boost

Error while using Boost with Visual Studio 2008

I am using Boost with Visual Studio 2008 and I have put the path to boost directory in configuration for the project in C++/General/"Additional Include Directories" and in Linker/General/"Additional Library Directories". (as it says here: http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html#build-from-the-visual-studio-...

How to iterate over a boost::fusion sequence?

I'm trying to initialise a list of args to use with fusion::invoke. The args are all of the form: template <typename Type> struct ArgWrapper { inline ArgWrapper(){} inline void Setup(lua_State*L,int idx) { //setup this value from the lua state... //in reality this class is specialised for different lua types ...

Boost beginner, boost::bind nightmare

Hello, I've got this header (redone from a boost asio example): #ifndef MSGSRV_H_ #define MSGSRV_H_ #include <asio.hpp> #include <boost/array.hpp> #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <boost/system/error_code.hpp> namespace msgSrv { class msgSrv { private: asio::ip::udp::socket *asioSocket; ...

boost::shared_ptr and multithreaded access

Hi! I'm trying to implement a multithreaded framework, in which output objects are created at the end of every frame that my networking thread runs, so that another thread can, at the beginning of its frame, obtain the most recent "completed output" pointer and know that it has safe and complete read-only access to any data stored withi...

Is there a boost smart pointer class that can be configured not to delete at destruction?

I have a list of smart pointers. I want some of these smart pointers to act as regular pointers, meaning they are simply a reference to an instance and are not involved in its deallocation. They might for example point to instances allocated on the stack. The other smart pointers in the list should act as regular boost::shared_ptr. He...

C++ Boost io streams, error handling

Is it possible to make a custom stream work like the stanadrd ones in regard for errors? That is by default use the good/fail/bad/eof bits rather than exceptions? The boost docs only mention throwing an std::failure for stream errors and letting other error propagate (eg a badalloc from trying to allocate a buffer), however the boost co...

How to compile a simple boost program from command line in unix

Say I have the path to the headers and lib files of boost, in $BOOST_INLCUDE and $BOOST_LIB how do I build a simple hello world? thanks ...

c++ namespace collision with gtest and boost

If I include both gtest/gtest.h and boost/math/distributions/poisson.hpp I get /opt/local/include/boost/tr1/tuple.hpp:63: error: ‘tuple’ is already declared in this scope /opt/local/include/boost/tr1/tuple.hpp:67: error: ‘make_tuple’ is already declared in this scope /opt/local/include/boost/tr1/tuple.hpp:68: error: ‘tie’ is already dec...

Binding to a member variable

Hi, I am confused as to what boost::bind does when we bind to member variables. With binding to member function, we essentially create a function object, and then call it passing to it the arguments that are provided or delayed and substituted via placeholders. But what does this expression do behind the scenes: boost::bind(&std::pair...

What is the performance of boost::interprocess_mutex vs Win32 native mutexes?

Note that I can conduct the research inside the boost source code, and may do this to answer my own curiosity if there isn't anyone out there with an answer. I do ask however because maybe someone has already done this comparison and can answer authoritatively? It would seem that creating a shared memory mapped file between processes, ...

unix timestamp to boost::posix_time::ptime

I need to convert double with number of seconds since the epoch to ptime. I'm prety sure there must be an easy way to do this, but I couldn't find anything. Thanks. Edit: The original timestamp is floating point. I can't change it and i don't want to lose the sub-second precision. ...

C++ GCC4.4 warning: array subscript is above array bounds

I recently upgraded to GCC 4.4 (MinGW TDM build) and now the follow code produces these warning: In member function 'void Console::print(const std::string&)': warning: array subscript is above array bounds Here's the code: void Console::print( const std::string& str ) { std::string newLine( str ); if( newLine.size()...

Should use an insertion sort or construct a heap to improve performance?

We have large (100,000+ elements) ordered vectors of structs (operator < overloaded to provide ordering): std::vector < MyType > vectorMyTypes; std::sort(vectorMyType.begin(), vectorMyType.end()); My problem is that we're seeing performance problems when adding new elements to these vectors while preserving sort order. At the moment ...

Annotatable Control Flow Graph with Boost?

I have a control flow graph representing a single procedure of my intermediate language code. Nodes and Edges are annotated via vertex/edge properties and contain instructions resp branch information. Now I want to perform data flow analysis on this graph and feed that graph into each data flow analysis module. Each module should be ab...

Boost unit test failure detected in wrong test suite

I'm learning how to use the Boost Test Library at the moment, and I can't seem to get test suites to work correctly. In the following code 'test_case_1' fails correctly but it's reported as being in the Master Test Suite instead of 'test_suite_1'. Anyone know what I'm doing wrong? #define BOOST_AUTO_TEST_MAIN #include <boost/test/auto...

Is it possible to instruct MSVC to use release version of Boost when compiling Debug project?

I have built Boost in Release configuration and have staged it into one folder. Now when I add Boost libraries into project and try to build it in Debug configuration - linker fails because there are no Debug versions libraries. Is there a way to make MSVC 9.0 use Release version of libraries when building Debug configuration? Of cours...

gcc linker errors when using boost to_lower & trim

Hi I'm trying to use the boost library in my code but get the following linker errors under Sparc Solaris platform. The problem code can essentially be summarised to: #include <boost/algorithm/string.hpp> std::string xparam; ... xparam = boost::to_lower(xparam); The linker error is: LdapClient.cc:349: no match for `std::string& ...

Numerical Conversion in C/C++

I need to convert a C/C++ double to a 64 bit two's complement, where the Radix point is at bit number 19 (inclusive). This means that for the format I want to convert to 0x0000 0000 0010 0000 is the number 1 0xFFFF FFFF FFF0 0000 is the number -1 0x0000 0000 0000 0001 is 0.95 x 10^-6 0xFFFF FFFF FFFF FFFF is -0.95 x 10^-6 So far ...

How do I take ownership of an abandoned boost::interprocess::interprocess_mutex?

Hi, My scenario: one server and (some clients (though not many). The server can only respond to one client at a time, so they must be queued up. I'm using a mutex (boost::interprocess::interprocess_mutex) to do this, wrapped in a boost::interprocess::scoped_lock. The thing is, if one client dies unexpectedly (i.e. no destructor runs) ...

Determine compile-time existence of include files in C++

I'm trying to write some portable C++ library code that will initially rely on Boost.Regex, and then move to TR1 as compilers support it, and eventually to the C++0x specification after things get moved from the std::tr1 namespace to std. Here is some pseudo-code for what I'd like to do with the preprocessor: if( exists(regex) ) // c...