]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/units/include/boost/units/detail/one.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / units / include / boost / units / detail / one.hpp
CommitLineData
7c673cae
FG
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
16namespace boost {
17
18namespace units {
19
20struct one { one() {} };
21
22// workaround for pathscale.
23inline one make_one() {
24 one result;
25 return(result);
26}
27
28template<class T>
29struct multiply_typeof_helper<one, T>
30{
31 typedef T type;
32};
33
34template<class T>
35struct multiply_typeof_helper<T, one>
36{
37 typedef T type;
38};
39
40template<>
41struct multiply_typeof_helper<one, one>
42{
43 typedef one type;
44};
45
46template<class T>
47inline T operator*(const one&, const T& t)
48{
49 return(t);
50}
51
52template<class T>
53inline T operator*(const T& t, const one&)
54{
55 return(t);
56}
57
58inline one operator*(const one&, const one&)
59{
60 one result;
61 return(result);
62}
63
64template<class T>
65struct divide_typeof_helper<T, one>
66{
67 typedef T type;
68};
69
70template<class T>
71struct divide_typeof_helper<one, T>
72{
73 typedef T type;
74};
75
76template<>
77struct divide_typeof_helper<one, one>
78{
79 typedef one type;
80};
81
82template<class T>
83inline T operator/(const T& t, const one&)
84{
85 return(t);
86}
87
88template<class T>
89inline T operator/(const one&, const T& t)
90{
91 return(1/t);
92}
93
94inline one operator/(const one&, const one&)
95{
96 one result;
97 return(result);
98}
99
100template<class T>
101inline bool operator>(const boost::units::one&, const T& t) {
102 return(1 > t);
103}
104
105template<class T>
106T one_to_double(const T& t) { return t; }
107
108inline double one_to_double(const one&) { return 1.0; }
109
110template<class T>
111struct one_to_double_type { typedef T type; };
112
113template<>
114struct one_to_double_type<one> { typedef double type; };
115
116} // namespace units
117
118} // namespace boost
119
120#endif