boost

C++ vectors question

Hello! Does anyone know how to speed up boost::numeric::ublas::vector? I am using typedef ublas::vector<float, ublas::bounded_array<float, 3> > MYVECTOR3 and compare it's speed to D3DXVECTOR3 on plain operations. The test look the following way: #include <d3dx9.h> #pragma comment(lib, "d3dx9.lib") static const size_t kRuns = static_...

"Equivalent" is equivalent to... in concept definitions

What does "equivalent" mean in the definition of concepts, such as http://www.boost.org/doc/libs/1_43_0/libs/utility/CopyConstructible.html? Shallow copy? Deep copy? Either? ...

Algorithm to find multiple string matches

I'm looking for suggestions for an efficient algorithm for finding all matches in a large body of text. Terms to search for will be contained in a list and can have 1000+ possibilities. The search terms may be 1 or more words. Obviously I could make multiple passes through the text comparing against each search term. Not too efficient. ...

The boost "signature" question

I'm trying to figure out how could many boost classes be able to accept a function signature as template argument and then "extract" from there the result type, first argument type and so on. template <class Signature> class myfunction_ptr { Signature* fn_ptr; public: typedef /*something*/ result_type; // How can I define this? ...

scoped_ptr for structure with substituted free method

I have a structure typedef struct myStruct_st { int a; }myStruct; It can be created using myStruct * myStruct_new() { printf("Allocate\n"); return new myStruct; } And deleted using static void myStruct_free(myStruct * ptr) { printf("Deallocate\n"); delete ptr; } I want the memory allocated for the structure freed au...

Typedef Generalisation

Hi, I need to generalise a C++ typedef so I do not need to copy and paste a lot of code. I am serializing blitz arrays using boost and I am defining my own load and save methods and need to do this based on template parameters. Basically I don't know how to generalize typedef blitz::Array<double, 2> my_Matrix; for higher order te...

C++ container question

Hello! I was looking for some suitable 2D element container. What I want is the ability to iterate through every element of the container using, for example BOOST_FOREACH and I also would like to have an ability to construct subview (slices / subranges) of my container and, probably iterate through them too. Right now I am using boost:...

extractin/building boost program_options

I have successfully installed boost, compiled binaries, and built bcp. I have also been able to extract the regex library using bcp. After doing this, I found a gcc_gen.sh script and bunch of makefiles under my_exported_boost_regex/libs/regex/build/ and used one of them to make my_exported_boost_regex/libs/regex/build/gcc/libboos...

How to create a comparator with Boost?

I'm new to Boost, but not to functional programming, and I'm trying to see where Boost can help me out. I have a list of 2D points, and I want to extract the minimum x coordinate. The Point class has a member function float x() const so I can use boost::mem_fn as follows: boost::mem_fn(&Point::x) But in order to use std::min_element,...

Rounding to nearest number in C++ using Boost?

Is there a way to round to the nearest number in the Boost library? I mean any number, 2's, 5's, 17's and so on and so forth. Or is there another way to do it? ...

Sending parameters to a DLL to be boost::bind'ed

I have a DLL which has a function which accepts a function pointer converts it to a boost::function. This is then stored and then called from inside the DLL. I want to add a function to the DLL to handle member functions in a similar way. I know I need to use boost::bind to wrap the member function pointer and the object together. I wan...

Any obvious problems or improvements for my producer consumer queue.

I asked a previous question about producer/consumer code that was overly general (though the answers were certainly helpful). So I've taken the suggestions from an earlier SO question by another author and converted them to C++ and boost. However I'm always a bit concerned about multithreaded code - so if anyone can see any obvious impro...

Is there an alternative for boost::phoenix::at_c in combination with boost::spirit::qi::grammar

I have created a test application to illustrate my problem. It parses a list of integers preceded by "a=" or "b=" and is separated by "\r\n". The list contains multiple occurrences of those fields in any order. #include <string> #include <vector> #include <iostream> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/includ...

Pass boost::signal as boost::function

I have a class with signal member encapsulated with boost::function. Is it possible to add another signal as a handler with this API? class Foo { public: VOID AddHandler(boost::function<VOID()> handler) { m_signal.connect(handler); } private: boost::signal<VOID()> m_signal; }; boost::signal<VOID()> signal; VOID SignalC...

Updating XML file using Boost property_tree

I have the following XML file: <xml version="1.0" encoding="utf-8"?> <Data> <Parameter1>1</Parameter1> </Data> I want to add a new node: Parameter2="2" to the Data node. This code doesn't work, saved file still contains only one parameter: boost::property_tree::ptree tree; boost::property_tree::ptree dataTree; read...

C++ shared_ptr - attach to a new raw pointer?

I think I'm missing something simple here. I'm using Boost's shared_ptr. shared_ptr<Foo> pA(new Foo()); shared_ptr<Foo> pB(new Foo()); Now, I want to switch pB so it contains the contents of pA, decrementing the ref count of pB. How can I do this? ...

ARG! Contravarience foils callback plot! Want to change virtual return type..

Hello all, I am working on a AI dynamic link library. It is to be explicitly linked and all of this is handled by a simple header include. I am at the moment trying to create the code for the DLL to be able to call functions in the main EXE to manipulate the world and also to be able to query functions to learn about the state of the ...

installing boost 1.42 (or any other version) on Vista with Visual Studio 2010

Hello, I want to install boost library on ma PC with Vista and Visual Studio 2010. First of all a downloaded boost 1.42 from official site and unpacked to c:\boost_1_42_0 Then I invoked bootstrap.bat but i get some errors: c:\boost_1_42_0>bootstrap.bat Building Boost.Jam build engine Failed to build Boost.Jam build engine. Please con...

shared_ptr by reference or by value?

When a function should take a boost::shared_ptr, are you passing it by const reference void foo(const boost::shared_ptr<T>& p) or by value void foo(boost::shared_ptr<T> p) ? I would prefer the first method because I suspect it to be faster. But is this really worth a though or are there any additional issues? Edit: Could you please g...

Error in template function (using Boost.Tuples)

#include <list> #include <boost/tuple/tuple.hpp> template<class InputIterator> void f(InputIterator it) { typedef boost::tuple<typename InputIterator::value_type, int> Pair; std::list<Pair> paired; typename std::list<Pair>::const_iterator output; for(output=paired.begin(); output!=paired.end(); ++output) { ou...