Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/units/detail/one.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and | |
2 // unit/quantity manipulation and conversion | |
3 // | |
4 // Copyright (C) 2003-2008 Matthias Christian Schabel | |
5 // Copyright (C) 2008 Steven Watanabe | |
6 // | |
7 // Distributed under the Boost Software License, Version 1.0. (See | |
8 // accompanying file LICENSE_1_0.txt or copy at | |
9 // http://www.boost.org/LICENSE_1_0.txt) | |
10 | |
11 #ifndef BOOST_UNITS_DETAIL_ONE_HPP | |
12 #define BOOST_UNITS_DETAIL_ONE_HPP | |
13 | |
14 #include <boost/units/operators.hpp> | |
15 | |
16 namespace boost { | |
17 | |
18 namespace units { | |
19 | |
20 struct one { one() {} }; | |
21 | |
22 // workaround for pathscale. | |
23 inline one make_one() { | |
24 one result; | |
25 return(result); | |
26 } | |
27 | |
28 template<class T> | |
29 struct multiply_typeof_helper<one, T> | |
30 { | |
31 typedef T type; | |
32 }; | |
33 | |
34 template<class T> | |
35 struct multiply_typeof_helper<T, one> | |
36 { | |
37 typedef T type; | |
38 }; | |
39 | |
40 template<> | |
41 struct multiply_typeof_helper<one, one> | |
42 { | |
43 typedef one type; | |
44 }; | |
45 | |
46 template<class T> | |
47 inline T operator*(const one&, const T& t) | |
48 { | |
49 return(t); | |
50 } | |
51 | |
52 template<class T> | |
53 inline T operator*(const T& t, const one&) | |
54 { | |
55 return(t); | |
56 } | |
57 | |
58 inline one operator*(const one&, const one&) | |
59 { | |
60 one result; | |
61 return(result); | |
62 } | |
63 | |
64 template<class T> | |
65 struct divide_typeof_helper<T, one> | |
66 { | |
67 typedef T type; | |
68 }; | |
69 | |
70 template<class T> | |
71 struct divide_typeof_helper<one, T> | |
72 { | |
73 typedef T type; | |
74 }; | |
75 | |
76 template<> | |
77 struct divide_typeof_helper<one, one> | |
78 { | |
79 typedef one type; | |
80 }; | |
81 | |
82 template<class T> | |
83 inline T operator/(const T& t, const one&) | |
84 { | |
85 return(t); | |
86 } | |
87 | |
88 template<class T> | |
89 inline T operator/(const one&, const T& t) | |
90 { | |
91 return(1/t); | |
92 } | |
93 | |
94 inline one operator/(const one&, const one&) | |
95 { | |
96 one result; | |
97 return(result); | |
98 } | |
99 | |
100 template<class T> | |
101 inline bool operator>(const boost::units::one&, const T& t) { | |
102 return(1 > t); | |
103 } | |
104 | |
105 template<class T> | |
106 T one_to_double(const T& t) { return t; } | |
107 | |
108 inline double one_to_double(const one&) { return 1.0; } | |
109 | |
110 template<class T> | |
111 struct one_to_double_type { typedef T type; }; | |
112 | |
113 template<> | |
114 struct one_to_double_type<one> { typedef double type; }; | |
115 | |
116 } // namespace units | |
117 | |
118 } // namespace boost | |
119 | |
120 #endif |