|
| 1 | + |
| 2 | +// Copyright John McFarlane 2021. |
| 3 | +// Distributed under the Boost Software License, Version 1.0. |
| 4 | +// (See accompanying file ../LICENSE_1_0.txt or copy at |
| 5 | +// http://www.boost.org/LICENSE_1_0.txt) |
| 6 | + |
| 7 | +#if !defined(CNL_IMPL_SCALED_QUASI_EXACT_CONVERT_OPERATOR_H) |
| 8 | +#define CNL_IMPL_SCALED_QUASI_EXACT_CONVERT_OPERATOR_H |
| 9 | + |
| 10 | +#include "../../../floating_point.h" |
| 11 | +#include "../../../fraction.h" |
| 12 | +#include "../../custom_operator/native_tag.h" |
| 13 | +#include "../../num_traits/fixed_width_scale.h" |
| 14 | +#include "../../num_traits/scale.h" |
| 15 | +#include "../../power_value.h" |
| 16 | +#include "../../scaled_integer/definition.h" |
| 17 | + |
| 18 | +/// compositional numeric library |
| 19 | +namespace cnl { |
| 20 | + template<number Src, int SrcExponent, number Dest, int DestExponent, int Radix> |
| 21 | + struct custom_operator< |
| 22 | + _impl::convert_op, |
| 23 | + op_value<Src, quasi_exact<SrcExponent, Radix>>, |
| 24 | + op_value<Dest, quasi_exact<DestExponent, Radix>>> |
| 25 | + : custom_operator< |
| 26 | + _impl::convert_op, |
| 27 | + op_value<Src, power<SrcExponent, Radix>>, |
| 28 | + op_value<Dest, power<DestExponent, Radix>>> { |
| 29 | + }; |
| 30 | + |
| 31 | + // shims between equivalent tags |
| 32 | + template<typename Input, typename Result, int DestExponent, int DestRadix> |
| 33 | + struct custom_operator< |
| 34 | + _impl::convert_op, |
| 35 | + op_value<Input>, |
| 36 | + op_value<Result, quasi_exact<DestExponent, DestRadix>>> |
| 37 | + : custom_operator< |
| 38 | + _impl::convert_op, |
| 39 | + op_value<Input>, |
| 40 | + op_value<Result, power<DestExponent, DestRadix>>> { |
| 41 | + }; |
| 42 | + |
| 43 | + template<typename Input, int SrcExponent, int SrcRadix, typename Result> |
| 44 | + struct custom_operator< |
| 45 | + _impl::convert_op, |
| 46 | + op_value<Input, quasi_exact<SrcExponent, SrcRadix>>, |
| 47 | + op_value<Result>> |
| 48 | + : custom_operator< |
| 49 | + _impl::convert_op, |
| 50 | + op_value<Input, power<SrcExponent, SrcRadix>>, |
| 51 | + op_value<Result>> { |
| 52 | + }; |
| 53 | +} |
| 54 | + |
| 55 | +#endif // CNL_IMPL_SCALED_QUASI_EXACT_CONVERT_OPERATOR_H |
0 commit comments