]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/include/boost/numeric/odeint/util/unit_helper.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / numeric / odeint / include / boost / numeric / odeint / util / unit_helper.hpp
1 /*
2 [auto_generated]
3 boost/numeric/odeint/util/unit_helper.hpp
4
5 [begin_description]
6 Get and set the value of a unit.
7 [end_description]
8
9 Copyright 2012-2013 Karsten Ahnert
10 Copyright 2012-2013 Mario Mulansky
11
12 Distributed under the Boost Software License, Version 1.0.
13 (See accompanying file LICENSE_1_0.txt or
14 copy at http://www.boost.org/LICENSE_1_0.txt)
15 */
16
17
18 #ifndef BOOST_NUMERIC_ODEINT_UTIL_UNIT_HELPER_HPP_INCLUDED
19 #define BOOST_NUMERIC_ODEINT_UTIL_UNIT_HELPER_HPP_INCLUDED
20
21
22 #ifndef __CUDACC__
23 #include <boost/units/quantity.hpp>
24 #include <boost/units/get_dimension.hpp>
25 #include <boost/units/get_system.hpp>
26 #endif
27
28
29
30 namespace boost {
31 namespace numeric {
32 namespace odeint {
33
34
35 namespace detail {
36
37 template<class T , class Enabler = void >
38 struct get_unit_value_impl
39 {
40 static T value(const T &t)
41 {
42 return t;
43 }
44 typedef T result_type;
45 };
46
47 #ifndef __CUDACC__
48 template<class Unit , class T>
49 struct get_unit_value_impl< boost::units::quantity< Unit , T> >
50 {
51 static T value( const boost::units::quantity< Unit , T> &t )
52 {
53 return t.value();
54 }
55 typedef T result_type;
56 };
57 #endif
58
59
60
61
62
63 template<class T , class V , class Enabler = void >
64 struct set_unit_value_impl
65 {
66 static void set_value(T &t , const V &v)
67 {
68 t = v;
69 }
70 };
71
72 #ifndef __CUDACC__
73 template<class Unit , class T , class V>
74 struct set_unit_value_impl<boost::units::quantity<Unit , T> , V>
75 {
76 static void set_value(boost::units::quantity<Unit , T> &t , const V &v)
77 {
78 t = boost::units::quantity<Unit , T>::from_value(v);
79 }
80 };
81 #endif
82
83
84
85 } // namespace detail
86
87
88 template<class T>
89 typename detail::get_unit_value_impl<T>::result_type get_unit_value(const T &t)
90 {
91 return detail::get_unit_value_impl<T>::value(t);
92 }
93
94
95 template<class T , class V>
96 void set_unit_value(T &t , const V &v)
97 {
98 return detail::set_unit_value_impl<T , V>::set_value(t , v);
99 }
100
101
102
103 template< class T >
104 struct unit_value_type
105 {
106 typedef T type;
107 };
108
109 #ifndef __CUDACC__
110 template< class Unit , class Y >
111 struct unit_value_type< boost::units::quantity< Unit , Y > >
112 {
113 typedef Y type;
114 };
115 #endif
116
117
118
119
120
121
122
123
124
125
126 template< typename Time >
127 struct inverse_time
128 {
129 typedef Time type;
130 };
131
132 #ifndef __CUDACC__
133 template< typename Unit , typename Value >
134 struct inverse_time< boost::units::quantity< Unit , Value > >
135 {
136 typedef boost::units::quantity< Unit , Value > time_type;
137 typedef typename boost::units::get_dimension< time_type >::type dimension;
138 typedef typename boost::units::get_system< time_type >::type system;
139 typedef typename boost::mpl::divides< boost::units::dimensionless_type , dimension >::type inv_dimension;
140 typedef boost::units::unit< inv_dimension , system > inv_unit;
141 typedef boost::units::quantity< inv_unit , Value > type;
142 };
143 #endif
144
145
146 } // namespace odeint
147 } // namespace numeric
148 } // namespace boost
149
150
151 #endif // BOOST_NUMERIC_ODEINT_UTIL_UNIT_HELPER_HPP_INCLUDED