OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
sparsegrid_util_common.hpp
1#ifndef SPARSEGRID_UTIL_COMMON
2#define SPARSEGRID_UTIL_COMMON
3
4template<typename base>
6{
7 base & b;
8
9 typedef typename base::value_type bt_type;
10
12 :b(b)
13 {}
14
15 auto operator[](int i) -> decltype(b[0])
16 {
17 b[0];
18 }
19
20 template<typename T>
22 {
23 for (int i = 0; i < b.size() ; i++)
24 {
25 b[i] = c;
26 }
27
28 return *this;
29 }
30
31 operator bt_type() const
32 {
33 return b[0];
34 }
35};
36
37// openfpm::detail::multi_array::sub_array_openfpm<T,N1,vmpl>
38
39template<typename T,typename vmpl>
40struct sparse_grid_bck_wrapper_impl<openfpm::detail::multi_array::sub_array_openfpm<T, 1, vmpl>>
41{
43
44
46 :b(b)
47 {}
48
49 auto operator[](int i) -> decltype(b[i][0])
50 {
51 return b[i][0];
52 }
53
54 auto operator[](int i) const -> decltype(b[i][0])
55 {
56 return b[i][0];
57 }
58};
59
60template<typename chunk_def>
62{
63 chunk_def bck;
64
65 sparse_grid_bck_value(chunk_def bck)
66 :bck(bck)
67 {}
68
69 template<unsigned int p>
70 auto get() -> sparse_grid_bck_wrapper_impl<typename std::remove_reference<decltype(bck.template get<p>())>::type>
71 {
72 return sparse_grid_bck_wrapper_impl<typename std::remove_reference<decltype(bck.template get<p>())>::type>(bck.template get<p>());
73 }
74
75 template<unsigned int p>
76 auto get() const -> sparse_grid_bck_wrapper_impl<typename std::remove_reference<decltype(bck.template get<p>())>::type>
77 {
78 return sparse_grid_bck_wrapper_impl<typename std::remove_reference<decltype(bck.template get<p>())>::type>(bck.template get<p>());
79 }
80};
81
82#endif
convert a type into constant type