OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
for_each_ref_host.hpp
1#ifndef OPENFPM_FOR_EACH_HOST_HPP_INCLUDED
2#define OPENFPM_FOR_EACH_HOST_HPP_INCLUDED
3
4
5// Copyright Aleksey Gurtovoy 2000-2008
6//
7// Distributed under the Boost Software License, Version 1.0.
8// (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// See http://www.boost.org/libs/mpl for documentation.
12
13// $Id: for_each.hpp 55648 2009-08-18 05:16:53Z agurtovoy $
14// $Date: 2009-08-17 22:16:53 -0700 (Mon, 17 Aug 2009) $
15// $Revision: 55648 $
16// Changed from Pietro incardona to handle reference functor
17
18#include "util/cuda_util.hpp"
19#include <boost/mpl/is_sequence.hpp>
20#include <boost/mpl/begin_end.hpp>
21#include <boost/mpl/apply.hpp>
22#include <boost/mpl/bool.hpp>
23#include <boost/mpl/next_prior.hpp>
24#include <boost/mpl/deref.hpp>
25#include <boost/mpl/identity.hpp>
26#include <boost/mpl/assert.hpp>
27#include <boost/mpl/aux_/unwrap.hpp>
28
29#include <boost/type_traits/is_same.hpp>
30#include <boost/utility/value_init.hpp>
31
32#if defined(__NVCC__) && !defined(__INTEL_COMPILER)
33#pragma hd_warning_disable
34#endif
35
36namespace boost { namespace mpl {
37
38namespace aux {
39
40template< bool done = true >
42{
43 template<
44 typename Iterator
45 , typename LastIterator
46 , typename TransformFunc
47 , typename F
48 >
49 static void execute(
50 Iterator*
51 , LastIterator*
52 , TransformFunc*
53 , F &
54 )
55 {
56 }
57};
58
59template<>
61{
62 template<
63 typename Iterator
64 , typename LastIterator
65 , typename TransformFunc
66 , typename F
67 >
68 static void execute(
69 Iterator*
70 , LastIterator*
71 , TransformFunc*
72 , F & f
73 )
74 {
75 typedef typename deref<Iterator>::type item;
76 typedef typename apply1<TransformFunc,item>::type arg;
77
78 // dwa 2002/9/10 -- make sure not to invoke undefined behavior
79 // when we pass arg.
80 value_initialized<arg> x;
81 aux::unwrap(f, 0)(boost::get(x));
82
83 typedef typename mpl::next<Iterator>::type iter;
85 ::execute( static_cast<iter*>(0), static_cast<LastIterator*>(0), static_cast<TransformFunc*>(0), f);
86 }
87};
88
89} // namespace aux
90
91// agurt, 17/mar/02: pointer default parameters are necessary to workaround
92// MSVC 6.5 function template signature's mangling bug
93template<
94 typename Sequence
95 , typename TransformOp
96 , typename F
97 >
98inline void for_each_ref_host(F & f, Sequence* = 0, TransformOp* = 0)
99{
100 BOOST_MPL_ASSERT(( is_sequence<Sequence> ));
101
102 typedef typename begin<Sequence>::type first;
103 typedef typename end<Sequence>::type last;
104
106 ::execute(static_cast<first*>(0), static_cast<last*>(0), static_cast<TransformOp*>(0), f);
107}
108
109template<
110 typename Sequence
111 , typename F
112 >
113inline
114void for_each_ref_host(F & f, Sequence* = 0)
115{
116 for_each_ref_host<Sequence, identity<> >(f);
117}
118
119}}
120
121#endif // OPENFPM_FOR_EACH_HPP_INCLUDED
[v_transform metafunction]