Blame boost/mpl/transform.hpp

Packit 58578d
Packit 58578d
#ifndef BOOST_MPL_TRANSFORM_HPP_INCLUDED
Packit 58578d
#define BOOST_MPL_TRANSFORM_HPP_INCLUDED
Packit 58578d
Packit 58578d
// Copyright Aleksey Gurtovoy 2000-2004
Packit 58578d
// Copyright David Abrahams 2003-2004
Packit 58578d
//
Packit 58578d
// Distributed under the Boost Software License, Version 1.0. 
Packit 58578d
// (See accompanying file LICENSE_1_0.txt or copy at 
Packit 58578d
// http://www.boost.org/LICENSE_1_0.txt)
Packit 58578d
//
Packit 58578d
// See http://www.boost.org/libs/mpl for documentation.
Packit 58578d
Packit 58578d
// $Id$
Packit 58578d
// $Date$
Packit 58578d
// $Revision$
Packit 58578d
Packit 58578d
#include <boost/mpl/fold.hpp>
Packit 58578d
#include <boost/mpl/reverse_fold.hpp>
Packit 58578d
#include <boost/mpl/pair_view.hpp>
Packit 58578d
#include <boost/mpl/is_sequence.hpp>
Packit 58578d
#include <boost/mpl/eval_if.hpp>
Packit 58578d
#include <boost/mpl/lambda.hpp>
Packit 58578d
#include <boost/mpl/bind.hpp>
Packit 58578d
#include <boost/mpl/or.hpp>
Packit 58578d
#include <boost/mpl/not.hpp>
Packit 58578d
#include <boost/mpl/aux_/na.hpp>
Packit 58578d
#include <boost/mpl/aux_/inserter_algorithm.hpp>
Packit 58578d
Packit 58578d
namespace boost { namespace mpl {
Packit 58578d
Packit 58578d
namespace aux { 
Packit 58578d
Packit 58578d
template< 
Packit 58578d
      typename Seq
Packit 58578d
    , typename Op
Packit 58578d
    , typename In
Packit 58578d
    >
Packit 58578d
struct transform1_impl
Packit 58578d
    : fold< 
Packit 58578d
          Seq
Packit 58578d
        , typename In::state
Packit 58578d
        , bind2< typename lambda< typename In::operation >::type
Packit 58578d
            , _1
Packit 58578d
            , bind1< typename lambda<Op>::type, _2>
Packit 58578d
            > 
Packit 58578d
        >
Packit 58578d
{
Packit 58578d
};
Packit 58578d
Packit 58578d
template< 
Packit 58578d
      typename Seq
Packit 58578d
    , typename Op
Packit 58578d
    , typename In
Packit 58578d
    >
Packit 58578d
struct reverse_transform1_impl
Packit 58578d
    : reverse_fold< 
Packit 58578d
          Seq
Packit 58578d
        , typename In::state
Packit 58578d
        , bind2< typename lambda< typename In::operation >::type
Packit 58578d
            , _1
Packit 58578d
            , bind1< typename lambda<Op>::type, _2>
Packit 58578d
            > 
Packit 58578d
        >
Packit 58578d
{
Packit 58578d
};
Packit 58578d
Packit 58578d
template< 
Packit 58578d
      typename Seq1
Packit 58578d
    , typename Seq2
Packit 58578d
    , typename Op
Packit 58578d
    , typename In
Packit 58578d
    >
Packit 58578d
struct transform2_impl
Packit 58578d
    : fold< 
Packit 58578d
          pair_view<Seq1,Seq2>
Packit 58578d
        , typename In::state
Packit 58578d
        , bind2< typename lambda< typename In::operation >::type
Packit 58578d
            , _1
Packit 58578d
            , bind2<
Packit 58578d
                  typename lambda<Op>::type
Packit 58578d
                , bind1<first<>,_2>
Packit 58578d
                , bind1<second<>,_2>
Packit 58578d
                >
Packit 58578d
            > 
Packit 58578d
        >
Packit 58578d
{
Packit 58578d
};
Packit 58578d
Packit 58578d
template< 
Packit 58578d
      typename Seq1
Packit 58578d
    , typename Seq2
Packit 58578d
    , typename Op
Packit 58578d
    , typename In
Packit 58578d
    >
Packit 58578d
struct reverse_transform2_impl
Packit 58578d
    : reverse_fold< 
Packit 58578d
          pair_view<Seq1,Seq2>
Packit 58578d
        , typename In::state
Packit 58578d
        , bind2< typename lambda< typename In::operation >::type
Packit 58578d
            , _1
Packit 58578d
            , bind2< typename lambda< Op >::type
Packit 58578d
                , bind1<first<>,_2>
Packit 58578d
                , bind1<second<>,_2>
Packit 58578d
                >
Packit 58578d
            > 
Packit 58578d
        >
Packit 58578d
{
Packit 58578d
};
Packit 58578d
Packit 58578d
} // namespace aux 
Packit 58578d
Packit 58578d
BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(3, transform1)                    
Packit 58578d
BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(4, transform2)
Packit 58578d
    
Packit 58578d
#define AUX778076_TRANSFORM_DEF(name)                                   \
Packit 58578d
template<                                                               \
Packit 58578d
      typename BOOST_MPL_AUX_NA_PARAM(Seq1)                             \
Packit 58578d
    , typename BOOST_MPL_AUX_NA_PARAM(Seq2OrOperation)                  \
Packit 58578d
    , typename BOOST_MPL_AUX_NA_PARAM(OperationOrInserter)              \
Packit 58578d
    , typename BOOST_MPL_AUX_NA_PARAM(Inserter)                         \
Packit 58578d
    >                                                                   \
Packit 58578d
struct name                                                             \
Packit 58578d
{                                                                       \
Packit 58578d
    typedef typename eval_if<                                           \
Packit 58578d
          or_<                                                          \
Packit 58578d
              is_na<OperationOrInserter>                                \
Packit 58578d
            , is_lambda_expression< Seq2OrOperation >                   \
Packit 58578d
            , not_< is_sequence<Seq2OrOperation> >                      \
Packit 58578d
            >                                                           \
Packit 58578d
        , name##1<Seq1,Seq2OrOperation,OperationOrInserter>             \
Packit 58578d
        , name##2<Seq1,Seq2OrOperation,OperationOrInserter,Inserter>    \
Packit 58578d
        >::type type;                                                   \
Packit 58578d
};                                                                      \
Packit 58578d
BOOST_MPL_AUX_NA_SPEC(4, name)                                          \
Packit 58578d
/**/
Packit 58578d
Packit 58578d
AUX778076_TRANSFORM_DEF(transform)
Packit 58578d
AUX778076_TRANSFORM_DEF(reverse_transform)
Packit 58578d
Packit 58578d
#undef AUX778076_TRANSFORM_DEF
Packit 58578d
Packit 58578d
}}
Packit 58578d
Packit 58578d
#endif // BOOST_MPL_TRANSFORM_HPP_INCLUDED