summaryrefslogtreecommitdiff
path: root/boost/units/derived_dimension.hpp
blob: 54cc46a3b159814c49d803f3eb80627b48551b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Boost.Units - A C++ library for zero-overhead dimensional analysis and 
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_UNITS_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_DERIVED_DIMENSION_HPP

#include <boost/units/dim.hpp>
#include <boost/units/dimension.hpp>
#include <boost/units/static_rational.hpp>
#include <boost/units/units_fwd.hpp>
#include <boost/units/detail/dimension_list.hpp>

namespace boost {

namespace units {

/// A utility class for defining composite dimensions with integer powers.
template<class DT1 = dimensionless_type,long E1 = 0,
         class DT2 = dimensionless_type,long E2 = 0,
         class DT3 = dimensionless_type,long E3 = 0,
         class DT4 = dimensionless_type,long E4 = 0,
         class DT5 = dimensionless_type,long E5 = 0,
         class DT6 = dimensionless_type,long E6 = 0,
         class DT7 = dimensionless_type,long E7 = 0,
         class DT8 = dimensionless_type,long E8 = 0>
struct derived_dimension
{
#ifdef BOOST_UNITS_DOXYGEN
    typedef detail::unspecified type;
#else
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >,
                         list< dim< DT3,static_rational<E3> >,
                         list< dim< DT4,static_rational<E4> >,
                         list< dim< DT5,static_rational<E5> >,
                         list< dim< DT6,static_rational<E6> >,
                         list< dim< DT7,static_rational<E7> >,
                         list< dim< DT8,static_rational<E8> >, dimensionless_type > > > > > > > > >::type type;
#endif
};

/// INTERNAL ONLY
template<class DT1,long E1>
struct derived_dimension<
    DT1, E1,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >, dimensionless_type > >::type type;
};

/// INTERNAL ONLY
template<class DT1,long E1,
         class DT2,long E2>
struct derived_dimension<
    DT1, E1,
    DT2, E2,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >, dimensionless_type > > >::type type;
};

/// INTERNAL ONLY
template<class DT1,long E1,
         class DT2,long E2,
         class DT3,long E3>
struct derived_dimension<
    DT1, E1,
    DT2, E2,
    DT3, E3,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >,
                         list< dim< DT3,static_rational<E3> >, dimensionless_type > > > >::type type;
};

/// INTERNAL ONLY
template<class DT1,long E1,
         class DT2,long E2,
         class DT3,long E3,
         class DT4,long E4>
struct derived_dimension<
    DT1, E1,
    DT2, E2,
    DT3, E3,
    DT4, E4,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >,
                         list< dim< DT3,static_rational<E3> >,
                         list< dim< DT4,static_rational<E4> >, dimensionless_type > > > > >::type type;
};

/// INTERNAL ONLY
template<class DT1,long E1,
         class DT2,long E2,
         class DT3,long E3,
         class DT4,long E4,
         class DT5,long E5>
struct derived_dimension<
    DT1, E1,
    DT2, E2,
    DT3, E3,
    DT4, E4,
    DT5, E5,
    dimensionless_type,0,
    dimensionless_type,0,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >,
                         list< dim< DT3,static_rational<E3> >,
                         list< dim< DT4,static_rational<E4> >,
                         list< dim< DT5,static_rational<E5> >, dimensionless_type > > > > > >::type type;
};

/// INTERNAL ONLY
template<class DT1,long E1,
         class DT2,long E2,
         class DT3,long E3,
         class DT4,long E4,
         class DT5,long E5,
         class DT6,long E6>
struct derived_dimension<
    DT1, E1,
    DT2, E2,
    DT3, E3,
    DT4, E4,
    DT5, E5,
    DT6, E6,
    dimensionless_type,0,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >,
                         list< dim< DT3,static_rational<E3> >,
                         list< dim< DT4,static_rational<E4> >,
                         list< dim< DT5,static_rational<E5> >,
                         list< dim< DT6,static_rational<E6> >, dimensionless_type > > > > > > >::type type;
};

/// INTERNAL ONLY
template<class DT1,long E1,
         class DT2,long E2,
         class DT3,long E3,
         class DT4,long E4,
         class DT5,long E5,
         class DT6,long E6,
         class DT7,long E7>
struct derived_dimension<
    DT1, E1,
    DT2, E2,
    DT3, E3,
    DT4, E4,
    DT5, E5,
    DT6, E6,
    DT7, E7,
    dimensionless_type,0>
{
    typedef typename 
    make_dimension_list< list< dim< DT1,static_rational<E1> >,
                         list< dim< DT2,static_rational<E2> >,
                         list< dim< DT3,static_rational<E3> >,
                         list< dim< DT4,static_rational<E4> >,
                         list< dim< DT5,static_rational<E5> >,
                         list< dim< DT6,static_rational<E6> >,
                         list< dim< DT7,static_rational<E7> >, dimensionless_type > > > > > > > >::type type;
};

} // namespace units

} // namespace boost                                                                   

#endif // BOOST_UNITS_DERIVED_DIMENSION_HPP