CNL  2.0.2 (development)
Compositional Numeric Library
ctors.h
1 
2 // Copyright John McFarlane 2019.
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_FRACTION_CTORS_H)
8 #define CNL_IMPL_FRACTION_CTORS_H
9 
10 #include "../../integer.h"
11 #include "make_fraction.h"
12 
13 #include "definition.h"
14 
15 #include <concepts>
16 
18 namespace cnl {
19  template<fixed_point Numerator, fixed_point Denominator>
20  constexpr fraction<Numerator, Denominator>::fraction(Numerator n, Denominator d)
21  : numerator{std::move(n)}
22  , denominator{std::move(d)}
23  {
24  }
25 
26  template<fixed_point Numerator, fixed_point Denominator>
27  template<integer Integer>
28  constexpr fraction<Numerator, Denominator>::fraction(Integer const& i)
29  : fraction(static_cast<Numerator>(i), 1)
30  {
31  }
32 
33  template<fixed_point Numerator, fixed_point Denominator>
34  template<fixed_point RhsNumerator, fixed_point RhsDenominator>
35  constexpr fraction<Numerator, Denominator>::fraction(
36  fraction<RhsNumerator, RhsDenominator> const& f)
37  : fraction(static_cast<Numerator>(f.numerator), static_cast<Numerator>(f.denominator))
38  {
39  }
40 
41  template<fixed_point Numerator, fixed_point Denominator>
42  template<std::floating_point FloatingPoint>
43  constexpr fraction<Numerator, Denominator>::fraction(FloatingPoint d)
44  : fraction(_impl::make_fraction<Numerator, Denominator>(d))
45  {
46  }
47 }
48 
49 #endif // CNL_IMPL_FRACTION_CTORS_H
std::move
T move(T... args)
cnl
compositional numeric library
Definition: abort.h:15