boost

Building Boost with LSB C++ Compiler

I want to build my program with LSB C++ Compiler from the Linux Standard Base http://www.linuxfoundation.org/collaborate/workgroups/lsb. Program depends on the Boost library, built with gcc 4.4 version. Compilation fails. Is it possible to build the Boost library with LSB C++ Compiler? Alternatively, is it possible to build the Boost lib...

Should boost library be dependent on structure member alignments?

I found, the hard way, that at least boost::program_options is dependent of the compiler configured structure member alignment. If you build boost using default settings and link it with a project using 4 bytes alignment (/Zp4) it will fail at runtime (made a minimal test with program_options). Boost will generate an assert indicating a...

Boost binding a function taking a reference

Hi all, I am having problems compiling the following snippet int temp; vector<int> origins; vector<string> originTokens = OTUtils::tokenize(buffer, ","); // buffer is a char[] array // original loop BOOST_FOREACH(string s, originTokens) { from_string(temp, s); origins.push_back(temp); } // I'd like to use this to repl...

Boost linker error

I'm new to boost lib and trying to compile a simple example about how the serialization works with boost library from http://www.boost.org/doc/libs/1_42_0/libs/serialization/example/demo.cpp on compiling i get the linker error: 1>LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc80-mt-sgd-1_42.lib' I also tried t...

number of months between two dates - using boost's date

I've used boost::gregorian::date a bit now. I can see that there are the related months & years & weeks duration types. I can see how to use known durations to advance a given date. Qu: But how can I get the difference between two dates in months (or years or weeks) ? I was hoping to find a function like: template<typename DURATION> ...

How can I decode the boost library naming?

I tried to find out that gd means in boost library name and I only found two other people looking for the same thing. I suppose it should be a place where this is clearly documented and I would like to find it. mt - multitheaded, get it with bjam threading=multi s - bjam runtime-link=static g - using debug versions of the standard and...

How to synchronize access to many objects

I have a thread pool with some threads (e.g. as many as number of cores) that work on many objects, say thousands of objects. Normally I would give each object a mutex to protect access to its internals, lock it when I'm doing work, then release it. When two threads would try to access the same object, one of the threads has to wait. No...

What's your convention for typedef'ing shared_ptr?

I'm flip-flopping between naming conventions for typedef'ing the boost::shared_ptr template. For example: typedef boost::shared_ptr<Foo> FooPtr; Before settling on a convention, I'd like to see what others use. What is your convention? EDIT: To those nesting the typedef inside Foo, doesn't it bother you that Foo is now "aware" of ho...

Boost bind with asio::placeholders::error

...

C++::Boost::Regex Iterate over the submatches

I am using Named Capture Groups with Boost Regex / Xpressive. I would like to iterate over all submatches, and get both the value and KEY of each submatch (i.e. what["type"]). sregex pattern = sregex::compile( "(?P<type>href|src)=\"(?P<url>[^\"]+)\"" ); sregex_iterator cur( web_buffer.begin(), web_buffer.end(), pattern ); sregex_i...

Boost serialization stamp?

when you try to serialize object data why do get 22 serialization::archive 7 in your serialized data? how do you get rid of it? ...

Makefile can not find boost libraries installed by macports

I just installed boost 1.42.0 from macports using sudo port install boost. Everything worked fine. Now I have a project that I'm trying to build using a makefile. Everything builds fine until it comes to the file that needs the boost library. It says: src/graph.h:20:42: error: boost/graph/adjacency_list.hpp: No such file or directo...

Display Graph using Boost Graph Library

Can anyone please tell me that once I've created a graph using Boost Graph library, how can I display that graph? My biggest concern is that the edge weights are coming from an exernal data source over the network. And I need to be able to display the edgeweights live as they get updated. ...

Serializing struct containing char*

I'm getting an error with serializing a char* string error C2228: left of '.serialize' must have class/struct/union I could use a std::string and then get a const char* from it. but I require the char* string. ...

How do I build boost examples with bjam?

Boost library is full of examples and tests and I would like to build them using bjam if possible. How do I build boost examples with bjam? PS. I wasn't able to locate proper documentation for this option. ...

boost::unordered_map support by gcc

When unoreded_map support was added to gcc? I'm using gcc 4.1.1 shipped with RHEL 5.3. It looks like unoreded_map is missing. Is there a way to add it manually? ...

Copy vector of values to vector of pairs in one line

I have the following types: struct X { int x; X( int val ) : x(val) {} }; struct X2 { int x2; X2() : x2() {} }; typedef std::pair<X, X2> pair_t; typedef std::vector<pair_t> pairs_vec_t; typedef std::vector<X> X_vec_t; I need to initialize instance of pairs_vec_t with values from X_vec_t. I use the following code and it ...

Can a trait state if a C++ class has a default constructor?

Traits classes can be defined to check if a C++ class has a member variable, function or a type (see here). Curiously, the ConceptTraits do not include traits to check if a C++ class defines a default constructor or given constructor? Can traits be used to check the constructor presence? If yes, how? If not, why it is not possible? ...

How to add a property to a module in boost::python?

You can add a property to a class using a getter and a setter (in a simplistic case): class<X>("X") .add_property("foo", &X::get_foo, &X::set_foo); So then you can use it from python like this: >>> x = mymodule.X() >>> x.foo = 'aaa' >>> x.foo 'aaa' But how to add a property to a module itself (not a class)? There is scope().a...

lexical_cast int to string

Is it safe to ignore exception of boost::lexical_cast when converting int to std::string? ...