Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-11-19 04:01:12


Hi Everyone,

Upon my daily chugging along with the very excellent Boost libraries,
I notice that I found myself writing a lot of boilerplate still
granted that we already have excellent libraries: Boost.Iterator,
Boost.Range, some of which aren't really that hard to implement in a
generic library such as Boost. Here's a couple of things that might be
good to ponder about, if people have the time to collaboratively build
these libraries:

* Boost.Range friendly versions of the STL algorithms -- although this
may be coming up in C++0x, seeing a version of std::copy,
std::transform, etc. that work with Boost.Range+Boost.Iterator combo's
will be very welcome. A simple code case is:

  std::copy(
    boost::make_filter_iterator_range(
      is_even()
    ),
    boost::make_function_output_iterator(
      my_serializer()
    )
  );

* SGI's select1st and select2nd generalized -- I'm not sure if you've
found yourself dealing with std::map's and std::list<std::pair<,> >'s
a lot, but I do, and there is a lot of merit in something like the
following:

  template <const N>
  struct select {
    template <class T>
    mpl::at_c<T, N>::type operator() (T element) const {
      return mpl::at_c<T, N>(element);
    };
  };

So that you can go ahead and see code like (with the STL adapters from above):

  std::transform(
    boost::make_range(my_map),
    select<1>(),
    std::ostream_iterator<my_map::value_type::second_type>(std::cout)
  );

If this is already under works, I'd love to find documentation or at
least progress. If this is already done and can be found somewhere,
links would be greatly appreciated. If there's interest, perhaps we
can build this in the sandbox and eventually get it reviewed and
submitted as part of boost?

Have a great day everyone, and keep them excellent libraries coming!

-- 
Dean Michael C. Berris
Software Engineer, Friendster, Inc.
[http://cplusplus-soup.blogspot.com/]
[mikhailberis_at_[hidden]]
[+63 928 7291459]
[+1 408 4049523]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk