Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_mpl_range_c.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_MPL_RANGE_C_HPP
11 #define SACADO_MPL_RANGE_C_HPP
12 
13 #include "Sacado_mpl_none.hpp"
14 #include "Sacado_mpl_size.hpp"
15 #include "Sacado_mpl_begin.hpp"
16 #include "Sacado_mpl_end.hpp"
17 #include "Sacado_mpl_next.hpp"
18 #include "Sacado_mpl_at.hpp"
19 #include "Sacado_mpl_deref.hpp"
21 
22 namespace Sacado {
23 
24  namespace mpl {
25 
26  // range_c tag for mpl operations
27  struct range_c_tag {};
28 
29  // range_c
30  template <class T, T N, T M, T Delta = 1>
31  struct range_c {
32  typedef range_c_tag tag;
33  typedef range_c type;
34  static const int sz = (M-N+Delta-1)/Delta;
35  typedef T integral_type;
36  static const int start_value = N;
37  static const int end_value = M;
38  static const int step_value = Delta;
39  };
40 
41  // iterator
42  template <class Range, int Pos>
44  static const int value = Pos;
45  };
46 
47  // size
48  template <>
50  template <class Range>
51  struct apply {
52  static const int value = Range::sz;
53  };
54  };
55 
56  // begin
57  template <>
59  template <class Range>
60  struct apply {
62  };
63  };
64 
65  // end
66  template <>
68  template <class Range>
69  struct apply {
71  };
72  };
73 
74  // next
75  template <class Range, int Pos>
76  struct next< range_c_iterator<Range,Pos> > {
78  };
79 
80 
81 
82  // at
83  template <int Pos>
84  struct at_impl<range_c_tag, Pos> {
85  template <class Range>
86  struct apply {
87  typedef integral_c<typename Range::integral_type,
88  Range::start_value + Range::step_value*Pos> type;
89  };
90  };
91 
92  // deref
93  template <class Range, int Pos>
94  struct deref< range_c_iterator<Range,Pos> > : mpl::at<Range,Pos> {};
95 
96  }
97 }
98 
99 #endif
integral_c< typename Range::integral_type, Range::start_value+Range::step_value *Pos > type
static const int end_value
static const int step_value
range_c_iterator< Range, Range::sz > type
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)
static const int start_value
#define T
Definition: Sacado_rad.hpp:553
const int N
int value