boost

Using boost to create a lambda function which always returns true

Suppose I have a function which takes some form of predicate: void Foo( boost::function<bool(int,int,int)> predicate ); If I want to call it with a predicate that always returns true, I can define a helper function: bool AlwaysTrue( int, int, int ) { return true; } ... Foo( boost::bind( AlwaysTrue ) ); But is there anyway to call t...

interaction problem with boost.signals2 ?

Hello. I'm trying to call a signal after an booost::asio::async_read from inside a function called by boost::asio::io_service. The run function runs in a thread, and the observers are connected in a different thread. This is causing errors. It's my program or it's not possible to invoke a handler that is running in another thread from i...

C++: How to check if a file/directory is readable? (PHP equivalent: is_readable)

I am trying to validate a directory with C++. http://php.net/manual/en/function.is-readable.php bool is_readable ( string $filename ) Tells whether a file (or directroy) exists and is readable. What would be the equivalent of the above in C++? I am already using the boost/filesystem library to check that the directory exists. I ha...

distributed unit testing/scenario based unit testing with boost.test

Hello, I am developing unit test cases for an application using Boost.test libraries. There are certain APIs which can directly be tested. But, there are APIs which require interaction between test machines. So for example, execution of a certain API in machine 1 should trigger an API in test machine 2 and its response needs to be use...

Using boost to create a lambda function which always throws

Is it possible to create an inline lambda using boost which always throws an exception? (this question follows on from "Using boost to create a lambda function which always returns true"). Suppose I have a function which takes some form of predicate: void Foo( boost::function<bool(int,int,int)> predicate ); If I want to call it with...

Build error with Boost Interprocess SharedMemory

In Boost::Interprocess "Creating maps in shared memory" section there's a sample. In the sample, std::allocator is used with 2 params: typedef allocator<ValueType, managed_shared_memory::segment_manager> ShmemAllocator; But standard allocator template is like that: template < class T > class allocator; So, how can it be?...

Comparison of Boost StateCharts vs. Samek's "Quantum Statecharts"

I've had heavy exposure to Miro Samek's "Quantum Hierarchical State Machine," but I'd like to know how it compares to Boost StateCharts - as told by someone who has worked with both. Any takers? ...

enable_shared_from_this and objects on stack

What about calling shared_from_this for stack allocated objects ? enable_shared_from_this in base classes list is indicator for user of derived class for creating it's only on heap (and we sholuld just hope for correct class usage) or we can have some more strong protection against such errors ? Or I don't understand some moments ? Examp...

Is there a native/reliable alternative for boost::shared_ptr in VC++ ?

My company doesn't allow the use of boost (for many stupid reasons, but that's off-topic). I feel very frustrated having to use raw pointers when I'm used to shared_ptr, weak_ptr and scoped_ptr for personal development. We're working exclusively with Microsoft compilers (Visual Studio 2010) and I wonder if there was an alternative to t...

Create linux make/build file

I am moving a C++ project from Windows to Linux and I now need to create a build/make file. I have never created a build/make file before. I also need to include Boost libraries to make it more complicated. It must also be a makefile and I need to learn how to create makefile anyway, so CMake and SCON are out. IDEs are also out because o...

boost::shared_ptr cycle break with weak_ptr

I am currently in a situation like: struct A { shared_ptr< B > b; } struct B { shared_ptr< A > a; } shared_ptr< A > a(new A()); shared_ptr< B > b(new B(); a->b(b); b->a(a); I know this won't work, because the references would continue to point to each other. I've also been told that weak_ptr solves this issue. However, weak ptr has no...

Multiple Boost.Thread Instances OK in a C++ application?

I have an application with a plug-in architecture that is using Boost.Threads as a DLL (specifically, a Mac OS X framework). I am trying to write a plug-in that uses Boost.Threads as well, and would like to link in the library statically. Everything builds fine but the application quickly crashes in my plug-in, deep within the Boost.Thre...

With drupal boost module any way to still have randomly loaded images

I am using Drupals boost module to cache my very dyanmic website. I also am using a views block to load in banner images from a content type and the view is set to randomly load an image. However, because boost module is caching the pages as html, what ever random images is loaded when the page is cached is what I am stuck with. Is ...

file rewriting with boost?

I would like to avoid using CreateFileMapping/MapViewOfFile to rewrite part of a file. Does boost provide this functionality? ...

Boost thread error

hello, #include <boost/thread/thread.hpp> #include <iostream> void hello() { std::cout << "Hello world, I'm a thread!" << std::endl; } int main(int argc, char* argv[]) { boost::thread thrd(&hello); thrd.join(); return 0; } i ran this program i am getting an error /usr/include/boost/thread/pthread/mutex.hpp:40: und...

Operator precendence in boost::spirit?

I made some tests using the spirit mini_c sample. Unfortunately it does not keep the operator precedence as expected: int main() { return 3 > 10 || 3 > 1; } evaluates to 0. return (3 > 10) || (3 > 1); returns 1 I tried to move the definition of "||" and "&&" to the very top in the constructor of template <typename Iterator> ...

Implementing "NOT" in boost::spirit mini_c

I tried to modify the mini_c example of boost::spirit to match to my existing vocabulary. I therefore added a operator "NOT that should behave equal as "!": unary_expr = primary_expr | ("NOT" > primary_expr [op(op_not)]) // This does not work | ('!' > primary_expr [op(op_not)]) | ('-' > p...

Boost serialization compiling issue

Hi, I am using boost serialization on windows, and I wanted to test my code on linux (ubuntu) and unfortunately it does not compile. #include <string> #include <fstream> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/nvp.hpp>...

Boost linking error for boost filesystem, why?

I have built boost 1.44 on CentOS 5.5 using the gcc that is part of CentOS 5.5. All targets built fine. However trying to build a simple cpp file with nothing but an include of boost filesystem results in this linking error (3 times): undefined reference to `boost::system::generic_category()' I cannot see why this would happen. The lib...

Creating object in the heap

Hello, I'm using boost::ptree for parsing fils. The problem is that I can't create the object in the heap. All samples is only for stack. #include <boost/property_tree/ptree.hpp> ptree *tree_handle; read_info("path", tree_handle); I need this because the code is in a function and I have to return the ptree-object from it. Errors: ‘b...