aimstil  5.0.5
fraction.h
Go to the documentation of this file.
1 #ifndef FRACTION_H_
2 #define FRACTION_H_
3 
9 
13 
14 
15 // includes from STL
16 #include <exception>
17 
18 namespace til
19 {
20 
21  //---------------------------------------------------------------------------
22 
25  template < typename T, typename ZeroByZeroPolicy >
26  class Fraction
27  {
28  public: // constructors -----------------------------------------------------
29  Fraction() : m_zeroByZeroPolicy() {}
30  Fraction(ZeroByZeroPolicy p) : m_zeroByZeroPolicy(p) {}
31  public: // functions --------------------------------------------------------
33  T operator()(T nom, T denom);
34  private: // data ------------------------------------------------------------
35  ZeroByZeroPolicy m_zeroByZeroPolicy;
36  };
37 
38  //---------------------------------------------------------------------------
39 
42  template < typename ZeroByZeroPolicy, typename T >
43  typename boost::enable_if_c<!std::numeric_limits<T>::is_integer, T>::type
44  fraction(T nom, T denom);
45 
46  //---------------------------------------------------------------------------
47 
48 } // namespace til
49 
50 // package include
51 #include "fraction.tpp"
52 #include "fraction_policies.h"
53 
54 #endif /*FRACTION_H_*/
Fraction(ZeroByZeroPolicy p)
Definition: fraction.h:30
boost::enable_if_c<!std::numeric_limits< T >::is_integer, T >::type fraction(T nom, T denom)
Divides one number by another.
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
A class to divide one number by another.
Definition: fraction.h:26
T operator()(T nom, T denom)
Returns nom / denom. The 0/0 case is handled by the policy.