AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
Range.hpp
1 #pragma once
2 
3 #include <type_traits>
4 
5 #include <amdis/common/Index.hpp>
6 #include <amdis/common/StaticSize.hpp>
7 
8 namespace AMDiS
9 {
10  namespace Impl
11  {
13  template <class Int, Int I, Int J>
14  struct range_impl
15  {
16  using type = range_impl;
17 
19  static constexpr auto begin() { return std::integral_constant<Int, I>{}; }
20 
22  static constexpr auto end() { return std::integral_constant<Int, J>{}; }
23 
25  template <std::size_t i>
26  constexpr auto operator[](index_t<i>) const
27  {
28  return std::integral_constant<Int, I+Int(i)>{};
29  }
30 
32  static constexpr bool empty() { return I >= J; }
33 
35  static constexpr auto size() { return std::integral_constant<Int, J-I>{}; }
36  };
37 
39  template <std::size_t I, class Int, Int begin, Int end>
40  constexpr auto get(range_impl<Int, begin, end> const& r) { return r[index_<I>]; }
41 
42  } // end namespace Impl
43 
44  template <std::size_t I, std::size_t J>
45  using range_t = Impl::range_impl<std::size_t, I, J>;
46 
47  template <std::size_t I, std::size_t J>
48  constexpr range_t<I,J> range_ = {};
49 
50 } // end namespace AMDiS
51 
52 namespace std
53 {
54  template <class Int, Int I0, Int I1>
55  class tuple_size<AMDiS::Impl::range_impl<Int,I0,I1>>
56  : public std::integral_constant<std::size_t, std::size_t(I1-I0)> {};
57 
58  template <std::size_t I, class Int, Int I0, Int I1>
59  class tuple_element<I,AMDiS::Impl::range_impl<Int,I0,I1>>
60  {
61  public:
62  using type = Int;
63  };
64 
65 } // end namespace std
Definition: FieldMatVec.hpp:12
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6