December 31, 2007
December 13, 2007
Play with boost.fusion
Today had spent some time playing with Boost.Fusion library, version 2. This is very interesting library, that will replace boost.tuple. I could mention, that this library has explicit functional background, and almost all operations are "lazy". And there are many thing was done to make this library very runtime efficient - it try to avoid elements copying, and also application of operations to elements done "on demand".
Library perform some of their functional in compile time, and rest of it - in runtime. Peoples, that like programming in functional style find well known functions - any, all, none, for_each, fold, etc., that could work with heterogeneous collections. And library also implements corresponding containers - lists, vectors, maps & cons cells.
So, using this library i could write following:
fold(make_vector(1,2,3,4),0,std::plusthat give us number equal 10. Some of the projects already use boost.fusion, for example, cpp-netlib project use it for holding data from parsing different protocols.())