|
Boost : |
From: Max Motovilov (max_at_[hidden])
Date: 2008-03-12 19:33:50
Ok, I have the recursive equivalent of my original implementation now.
About 2/3 in length, perhaps marginally easier to understand. However
2^7 combinations kick it (with VStudio 2008) into never-never-land and
the iterative solution takes it in stride, if not instantaneously.
So, do you think this thingie belongs in MPL?
...Max...
=====================================================================================
template< typename S > struct flatten_view;
template< typename S >
struct flatten_descend_once
{
typedef joint_view<
typename front<S>::type,
flatten_view<
iterator_range<
typename next<
typename begin< S >::type
>::type,
typename end< S >::type
>
>
>
type;
};
template< typename S >
struct flatten_view :
public eval_if<
typename empty<S>::type,
identity<S>,
flatten_descend_once<S>
>::type
{
typedef flatten_view type;
};
template< typename S, typename A> struct product_view_ex;
template< typename S, typename A >
struct product_descend_once
{
typedef flatten_view< transform_view<
typename front<S>::type,
product_view_ex<
typename pop_front<S>::type,
push_front<A,_1>
>
> >
type;
};
template< typename S, typename A>
struct product_view_ex :
public eval_if<
typename empty<S>::type,
push_back< S, A>,
product_descend_once< S, A >
>::type
{
typedef product_view_ex type;
};
template< typename S> struct product_view :
public if_<
typename empty<S>::type, S,
product_view_ex< S, typename clear<S>::type >
>::type
{
typedef product_view type;
};
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk