|
Boost : |
From: Dirk Gerrits (dirk_at_[hidden])
Date: 2002-10-30 16:37:40
Marc Jacobs wrote:
> I'd like to offer two submissions to Boost.
>
> ----------------------------
> The first is a straightforward implementation of a cartesian product
> on two
> ranges. That is, given iterators on two ranges, perform a binary operation
> on every combination of elements. Here is a pseudo-code example:
>
> r1 = { 'A', 'B', 'C' }
> r2 = { 'D', 'E', 'F' }
> // concat() is a binary functor that concatenates two characters into a
> string
> cartesian_product( r1.begin(), r1.end(), r2.begin(), r2.end(), concat() )
> // returns
> // 'AD', 'AE', 'AF', 'BD', 'BE', 'BF', 'CD', 'CE', 'CF'
>
Wouldn't it be more STL like to take an output iterator parameter and
return it after the function call? You know, like std::copy and such
algorithms.
Just a thought.
Regards,
Dirk Gerrits
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk