Blame view

3rdparty/boost_1_81_0/boost/qvm/quat_traits.hpp 2.23 KB
0b6a182c   Hu Chunming   添加无鉴权注册和注销
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  #ifndef BOOST_QVM_QUAT_TRAITS
  #define BOOST_QVM_QUAT_TRAITS
  
  // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
  
  // Distributed under the Boost Software License, Version 1.0. (See accompanying
  // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  
  #include <boost/qvm/is_scalar.hpp>
  #include <boost/qvm/enable_if.hpp>
  #include <boost/qvm/config.hpp>
  
  namespace boost { namespace qvm {
  
  template <class Q>
  struct
  quat_traits
      {
      typedef void scalar_type;
      };
  
  template <class T>
  struct
  is_quat
      {
      static bool const value = is_scalar<typename quat_traits<T>::scalar_type>::value;
      };
  
  namespace
  qvm_detail
      {
      template <class T, T>
      struct
      qtr_dispatch_yes
          {
          char x, y;
          };
      }
  
  template <class T>
  class
  quat_write_element_ref
      {
      template <class U>
      static qvm_detail::qtr_dispatch_yes<typename quat_traits<U>::scalar_type & (*)( U & ), &quat_traits<U>::template write_element<0> > check(int);
  
      template <class>
      static char check(long);
  
      public:
  
      static bool const value = sizeof(check<T>(0)) > 1;
      };
  
  template <int I, class Q>
  BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
  typename enable_if_c<
      quat_write_element_ref<Q>::value,
      void>::type
  write_quat_element( Q & q, typename quat_traits<Q>::scalar_type s )
      {
      quat_traits<Q>::template write_element<I>(q) = s;
      }
  
  template <int I, class Q>
  BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
  typename enable_if_c<
      !quat_write_element_ref<Q>::value,
      void>::type
  write_quat_element( Q & q, typename quat_traits<Q>::scalar_type s )
      {
      quat_traits<Q>::template write_element<I>(q, s);
      }
  
  template <class Q>
  BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
  typename enable_if_c<
      quat_write_element_ref<Q>::value,
      void>::type
  write_quat_element_idx( int i, Q & q, typename quat_traits<Q>::scalar_type s )
      {
      quat_traits<Q>::template write_element_idx(i, q) = s;
      }
  
  template <class Q>
  BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
  typename enable_if_c<
      !quat_write_element_ref<Q>::value,
      void>::type
  write_vec_element_idx( int i, Q & q, typename quat_traits<Q>::scalar_type s )
      {
      quat_traits<Q>::template write_element_idx(i, q, s);
      }
  
  } }
  
  #endif