Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:41:57

0001 
0002 #ifndef BOOST_MPL_UNIQUE_HPP_INCLUDED
0003 #define BOOST_MPL_UNIQUE_HPP_INCLUDED
0004 
0005 // Copyright Aleksey Gurtovoy 2000-2004
0006 // Copyright John R. Bandela 2000-2002
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. 
0009 // (See accompanying file LICENSE_1_0.txt or copy at 
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // See http://www.boost.org/libs/mpl for documentation.
0013 
0014 // $Id$
0015 // $Date$
0016 // $Revision$
0017 
0018 #include <boost/mpl/fold.hpp>
0019 #include <boost/mpl/reverse_fold.hpp>
0020 #include <boost/mpl/eval_if.hpp>
0021 #include <boost/mpl/and.hpp>
0022 #include <boost/mpl/identity.hpp>
0023 #include <boost/mpl/pair.hpp>
0024 #include <boost/mpl/apply.hpp>
0025 #include <boost/mpl/aux_/inserter_algorithm.hpp>
0026 #include <boost/mpl/aux_/na.hpp>
0027 #include <boost/mpl/aux_/na_spec.hpp>
0028 #include <boost/mpl/aux_/lambda_spec.hpp>
0029 
0030 namespace boost { namespace mpl {
0031 
0032 namespace aux {
0033 
0034 template< typename Predicate, typename Operation >
0035 struct unique_op
0036 {
0037     template< typename Pair, typename T > struct apply
0038     {
0039         typedef typename Pair::first seq_;
0040         typedef typename Pair::second prior_;
0041         typedef typename eval_if<
0042               and_< is_not_na<prior_>, apply2<Predicate,prior_,T> >
0043             , identity<seq_>
0044             , apply2<Operation,seq_,T>
0045             >::type new_seq_;
0046 
0047         typedef pair<new_seq_,T> type;
0048     };
0049 };
0050 
0051 template<
0052       typename Sequence
0053     , typename Predicate
0054     , typename Inserter
0055     >
0056 struct unique_impl
0057     : first< typename fold<
0058           Sequence
0059         , pair< typename Inserter::state,na >
0060         , protect< aux::unique_op<Predicate,typename Inserter::operation> >
0061         >::type >
0062 {
0063 };
0064 
0065 template<
0066       typename Sequence
0067     , typename Predicate
0068     , typename Inserter
0069     >
0070 struct reverse_unique_impl
0071     : first< typename reverse_fold<
0072           Sequence
0073         , pair< typename Inserter::state,na >
0074         , protect< aux::unique_op<Predicate,typename Inserter::operation> >
0075         >::type >
0076 {
0077 };
0078 
0079 } // namespace aux
0080 
0081 BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(3, unique)
0082 
0083 }}
0084 
0085 #endif // BOOST_MPL_UNIQUE_HPP_INCLUDED