| Home | Libraries | People | FAQ | More

## Struct flatten

boost::proto::functional::flatten — A PolymorphicFunctionObject type that returns a "flattened" view of a Proto expression tree.

## Synopsis

    // In header: <boost/proto/fusion.hpp>

    struct flatten :  proto::callable {
      // member classes/structs/unions
      template<typename This, typename Expr>
      struct result<This(Expr)> :  result< This(Expr const &) > {
      };
      template<typename This, typename Expr>
      struct result<This(Expr &)> :  proto::result_of::flatten< Expr > {
      };

      // public member functions
      template<typename Expr>
        typename proto::result_of::flatten< Expr >::type const
        operator()(Expr &) const;
      template<typename Expr>
        typename proto::result_of::flatten< Expr const >::type const
        operator()(Expr const &) const;
    };

## Description

A PolymorphicFunctionObject type that returns a "flattened" view of a Proto expression tree. For a tree with a top-most node tag of type `T`, the elements of the flattened sequence are determined by recursing into each child node with the same tag type and returning those nodes of different type. So for instance, the Proto expression tree corresponding to the expression `a | b | c` has a flattened view with elements [a, b, c], even though the tree is grouped as `((a | b) | c)`.

### `flatten` public member functions

1.     template<typename Expr>
         typename proto::result_of::flatten< Expr >::type const
         operator()(Expr & expr) const;

2.     template<typename Expr>
         typename proto::result_of::flatten< Expr const >::type const
         operator()(Expr const & expr) const;