]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/units/detail/absolute_impl.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / units / detail / absolute_impl.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_ABSOLUTE_IMPL_HPP
12#define BOOST_UNITS_ABSOLUTE_IMPL_HPP
13
14#include <iosfwd>
15
16#include <boost/units/config.hpp>
17#include <boost/units/conversion.hpp>
18#include <boost/units/heterogeneous_system.hpp>
19#include <boost/units/units_fwd.hpp>
20
21namespace boost {
22
23namespace units {
24
25/// INTERNAL ONLY
26template<class D, class S>
27struct reduce_unit<absolute<unit<D, S> > >
28{
29 typedef absolute<typename reduce_unit<unit<D, S> >::type> type;
30};
31
32namespace detail {
33
34struct undefined_affine_conversion_base {
11fdf7f2 35 BOOST_STATIC_CONSTEXPR bool is_defined = false;
7c673cae
FG
36};
37
38} // namespace detail
39
40/// INTERNAL ONLY
41template<class From, class To>
42struct affine_conversion_helper : detail::undefined_affine_conversion_base { };
43
44namespace detail {
45
46template<bool IsDefined, bool ReverseIsDefined>
47struct affine_conversion_impl;
48
49template<bool ReverseIsDefined>
50struct affine_conversion_impl<true, ReverseIsDefined>
51{
52 template<class Unit1, class Unit2, class T0, class T1>
53 struct apply {
11fdf7f2 54 static BOOST_CONSTEXPR T1 value(const T0& t0)
7c673cae
FG
55 {
56 return(
57 t0 *
58 conversion_factor(Unit1(), Unit2()) +
59 affine_conversion_helper<typename reduce_unit<Unit1>::type, typename reduce_unit<Unit2>::type>::value());
60 }
61 };
62};
63
64template<>
65struct affine_conversion_impl<false, true>
66{
67 template<class Unit1, class Unit2, class T0, class T1>
68 struct apply
69 {
11fdf7f2 70 static BOOST_CONSTEXPR T1 value(const T0& t0)
7c673cae
FG
71 {
72 return(
73 (t0 - affine_conversion_helper<typename reduce_unit<Unit2>::type, typename reduce_unit<Unit1>::type>::value()) *
74 conversion_factor(Unit1(), Unit2()));
75 }
76 };
77};
78
79} // namespace detail
80
81/// INTERNAL ONLY
82template<class Unit1, class T1, class Unit2, class T2>
83struct conversion_helper<quantity<absolute<Unit1>, T1>, quantity<absolute<Unit2>, T2> >
84{
85 typedef quantity<absolute<Unit1>, T1> from_quantity_type;
86 typedef quantity<absolute<Unit2>, T2> to_quantity_type;
11fdf7f2 87 static BOOST_CONSTEXPR to_quantity_type convert(const from_quantity_type& source)
7c673cae
FG
88 {
89 return(
90 to_quantity_type::from_value(
91 detail::affine_conversion_impl<
92 affine_conversion_helper<typename reduce_unit<Unit1>::type, typename reduce_unit<Unit2>::type>::is_defined,
93 affine_conversion_helper<typename reduce_unit<Unit2>::type, typename reduce_unit<Unit1>::type>::is_defined
94 >::template apply<Unit1, Unit2, T1, T2>::value(source.value())
95 )
96 );
97 }
98};
99
100} // namespace units
101
102} // namespace boost
103
104#endif // BOOST_UNITS_ABSOLUTE_IMPL_HPP