]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/qvm/quat_access.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / qvm / quat_access.hpp
1 #ifndef BOOST_QVM_QUAT_ACCESS_HPP_INCLUDED
2 #define BOOST_QVM_QUAT_ACCESS_HPP_INCLUDED
3
4 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
5
6 // Distributed under the Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <boost/qvm/inline.hpp>
10 #include <boost/qvm/quat_traits.hpp>
11 #include <boost/qvm/deduce_vec.hpp>
12 #include <boost/qvm/static_assert.hpp>
13 #include <boost/qvm/enable_if.hpp>
14
15 namespace boost { namespace qvm {
16
17 namespace
18 qvm_detail
19 {
20 template <class Q>
21 struct
22 quat_v_
23 {
24 template <class R>
25 operator R() const
26 {
27 R r;
28 assign(r,*this);
29 return r;
30 }
31
32 private:
33
34 quat_v_( quat_v_ const & );
35 quat_v_ const & operator=( quat_v_ const & );
36 ~quat_v_();
37 };
38 }
39
40 template <class V>
41 struct vec_traits;
42
43 template <class Q>
44 struct
45 vec_traits< qvm_detail::quat_v_<Q> >
46 {
47 typedef qvm_detail::quat_v_<Q> this_vector;
48 typedef typename quat_traits<Q>::scalar_type scalar_type;
49 static int const dim=3;
50
51 template <int I>
52 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
53 static
54 scalar_type
55 read_element( this_vector const & q )
56 {
57 BOOST_QVM_STATIC_ASSERT(I>=0);
58 BOOST_QVM_STATIC_ASSERT(I<dim);
59 return quat_traits<Q>::template read_element<I+1>( reinterpret_cast<Q const &>(q) );
60 }
61
62 template <int I>
63 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
64 static
65 scalar_type &
66 write_element( this_vector & q )
67 {
68 BOOST_QVM_STATIC_ASSERT(I>=0);
69 BOOST_QVM_STATIC_ASSERT(I<dim);
70 return quat_traits<Q>::template write_element<I+1>( reinterpret_cast<Q &>(q) );
71 }
72 };
73
74 template <class Q,int D>
75 struct
76 deduce_vec<qvm_detail::quat_v_<Q>,D>
77 {
78 typedef vec<typename quat_traits<Q>::scalar_type,D> type;
79 };
80
81 template <class Q,int D>
82 struct
83 deduce_vec2<qvm_detail::quat_v_<Q>,qvm_detail::quat_v_<Q>,D>
84 {
85 typedef vec<typename quat_traits<Q>::scalar_type,D> type;
86 };
87
88 template <class Q>
89 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
90 typename enable_if_c<
91 is_quat<Q>::value,
92 qvm_detail::quat_v_<Q> const &>::type
93 V( Q const & a )
94 {
95 return reinterpret_cast<qvm_detail::quat_v_<Q> const &>(a);
96 }
97
98 template <class Q>
99 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
100 typename enable_if_c<
101 is_quat<Q>::value,
102 qvm_detail::quat_v_<Q> &>::type
103 V( Q & a )
104 {
105 return reinterpret_cast<qvm_detail::quat_v_<Q> &>(a);
106 }
107
108 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type S( Q const & a ) { return quat_traits<Q>::template read_element<0>(a); }
109 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type X( Q const & a ) { return quat_traits<Q>::template read_element<1>(a); }
110 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type Y( Q const & a ) { return quat_traits<Q>::template read_element<2>(a); }
111 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type>::type Z( Q const & a ) { return quat_traits<Q>::template read_element<3>(a); }
112
113 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type &>::type S( Q & a ) { return quat_traits<Q>::template write_element<0>(a); }
114 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type &>::type X( Q & a ) { return quat_traits<Q>::template write_element<1>(a); }
115 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type &>::type Y( Q & a ) { return quat_traits<Q>::template write_element<2>(a); }
116 template <class Q> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_quat<Q>::value,typename quat_traits<Q>::scalar_type &>::type Z( Q & a ) { return quat_traits<Q>::template write_element<3>(a); }
117
118 } }
119
120 #endif