Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 #ifndef BOOST_MPL_FOR_EACH_HPP_INCLUDED
0003 #define BOOST_MPL_FOR_EACH_HPP_INCLUDED
0004 
0005 // Copyright Aleksey Gurtovoy 2000-2008
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. 
0008 // (See accompanying file LICENSE_1_0.txt or copy at 
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // See http://www.boost.org/libs/mpl for documentation.
0012 
0013 // $Id$
0014 // $Date$
0015 // $Revision$
0016 
0017 #include <boost/mpl/is_sequence.hpp>
0018 #include <boost/mpl/begin_end.hpp>
0019 #include <boost/mpl/apply.hpp>
0020 #include <boost/mpl/bool.hpp>
0021 #include <boost/mpl/next_prior.hpp>
0022 #include <boost/mpl/deref.hpp>
0023 #include <boost/mpl/identity.hpp>
0024 #include <boost/mpl/assert.hpp>
0025 #include <boost/mpl/aux_/config/gpu.hpp>
0026 #include <boost/mpl/aux_/unwrap.hpp>
0027 
0028 #include <boost/type_traits/is_same.hpp>
0029 #include <boost/utility/value_init.hpp>
0030 
0031 namespace boost { namespace mpl {
0032 
0033 namespace aux {
0034 
0035 template< bool done = true >
0036 struct for_each_impl
0037 {
0038     template<
0039           typename Iterator
0040         , typename LastIterator
0041         , typename TransformFunc
0042         , typename F
0043         >
0044     BOOST_MPL_CFG_GPU_ENABLED
0045     static void execute(
0046           Iterator*
0047         , LastIterator*
0048         , TransformFunc*
0049         , F
0050         )
0051     {
0052     }
0053 };
0054 
0055 template<>
0056 struct for_each_impl<false>
0057 {
0058     template<
0059           typename Iterator
0060         , typename LastIterator
0061         , typename TransformFunc
0062         , typename F
0063         >
0064     BOOST_MPL_CFG_GPU_ENABLED
0065     static void execute(
0066           Iterator*
0067         , LastIterator*
0068         , TransformFunc* 
0069         , F f
0070         )
0071     {
0072         typedef typename deref<Iterator>::type item;
0073         typedef typename apply1<TransformFunc,item>::type arg;
0074     
0075         // dwa 2002/9/10 -- make sure not to invoke undefined behavior
0076         // when we pass arg.
0077         value_initialized<arg> x;
0078         aux::unwrap(f, 0)(boost::get(x));
0079         
0080         typedef typename mpl::next<Iterator>::type iter;
0081         for_each_impl<boost::is_same<iter,LastIterator>::value>
0082             ::execute( static_cast<iter*>(0), static_cast<LastIterator*>(0), static_cast<TransformFunc*>(0), f);
0083     }
0084 };
0085 
0086 } // namespace aux
0087 
0088 // agurt, 17/mar/02: pointer default parameters are necessary to workaround 
0089 // MSVC 6.5 function template signature's mangling bug
0090 template<
0091       typename Sequence
0092     , typename TransformOp
0093     , typename F
0094     >
0095 BOOST_MPL_CFG_GPU_ENABLED
0096 inline
0097 void for_each(F f, Sequence* = 0, TransformOp* = 0)
0098 {
0099     BOOST_MPL_ASSERT(( is_sequence<Sequence> ));
0100 
0101     typedef typename begin<Sequence>::type first;
0102     typedef typename end<Sequence>::type last;
0103 
0104     aux::for_each_impl< boost::is_same<first,last>::value >
0105         ::execute(static_cast<first*>(0), static_cast<last*>(0), static_cast<TransformOp*>(0), f);
0106 }
0107 
0108 template<
0109       typename Sequence
0110     , typename F
0111     >
0112 BOOST_MPL_CFG_GPU_ENABLED
0113 inline
0114 void for_each(F f, Sequence* = 0)
0115 {
0116   // jfalcou: fully qualifying this call so it doesnt clash with phoenix::for_each
0117   // ons ome compilers -- done on 02/28/2011
0118   boost::mpl::for_each<Sequence, identity<> >(f);
0119 }
0120 
0121 }}
0122 
0123 #endif // BOOST_MPL_FOR_EACH_HPP_INCLUDED