GteArithmetic.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
15 #include <cmath>
16 #include <type_traits>
17 
18 namespace gte
19 {
20 
22 {
23 public:
24  // The tag-dispatch pattern is used for template-parameter-controlled
25  // instantiation of mathematical functions. See GteFunctions.h for
26  // examples of how to use this type-trait system.
27 
28  enum Type
29  {
30  IS_INVALID, // not an arithmetic type
31  IS_FLOATING_POINT, // 'float' or 'double' or 'long double'
32  IS_FP16, // IEEEBinary16
33  IS_BINARY_SCIENTIFIC // BSNumber or BSRational
34  };
35 
36  typedef std::integral_constant<Type, IS_INVALID> IsInvalidType;
37  typedef std::integral_constant<Type, IS_FLOATING_POINT> IsFPType;
38  typedef std::integral_constant<Type, IS_FP16> IsFP16Type;
39  typedef std::integral_constant<Type, IS_BINARY_SCIENTIFIC> IsBSType;
40 
41  template <typename T> struct WhichType : IsInvalidType{};
42  template <typename U> struct WhichType<BSNumber<U>> : IsBSType{};
43  template <typename U> struct WhichType<BSRational<U>> : IsBSType{};
44 };
45 
46 template<> struct Arithmetic::WhichType<float> : IsFPType{};
47 template<> struct Arithmetic::WhichType<double> : IsFPType{};
48 template<> struct Arithmetic::WhichType<long double> : IsFPType{};
50 
51 }
std::integral_constant< Type, IS_FP16 > IsFP16Type
Definition: GteArithmetic.h:38
std::integral_constant< Type, IS_FLOATING_POINT > IsFPType
Definition: GteArithmetic.h:37
std::integral_constant< Type, IS_BINARY_SCIENTIFIC > IsBSType
Definition: GteArithmetic.h:39
std::integral_constant< Type, IS_INVALID > IsInvalidType
Definition: GteArithmetic.h:36


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59