File indexing completed on 2025-01-18 09:51:03
0001 #ifndef BOOST_QVM_DEDUCE_QUAT_HPP_INCLUDED
0002 #define BOOST_QVM_DEDUCE_QUAT_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009 #include <boost/qvm/deduce_scalar.hpp>
0010 #include <boost/qvm/quat_traits.hpp>
0011 #include <boost/qvm/static_assert.hpp>
0012
0013 namespace boost { namespace qvm {
0014
0015 template <class T>
0016 struct quat;
0017
0018 namespace
0019 qvm_detail
0020 {
0021 template <class Q,class S,
0022 class QS=typename quat_traits<Q>::scalar_type>
0023 struct
0024 deduce_q_default
0025 {
0026 BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
0027 typedef quat<typename quat_traits<Q>::scalar_type> type;
0028 };
0029
0030 template <class Q,class S>
0031 struct
0032 deduce_q_default<Q,S,S>
0033 {
0034 BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
0035 typedef Q type;
0036 };
0037 }
0038
0039 template <class Q,class S=typename quat_traits<Q>::scalar_type>
0040 struct
0041 deduce_quat
0042 {
0043 BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
0044 typedef typename qvm_detail::deduce_q_default<Q,S>::type type;
0045 };
0046
0047 namespace
0048 qvm_detail
0049 {
0050 template <class A,class B,class S,
0051 bool IsScalarA=is_scalar<A>::value,
0052 bool IsScalarB=is_scalar<B>::value>
0053 struct
0054 deduce_q2_default
0055 {
0056 typedef quat<S> type;
0057 };
0058
0059 template <class Q,class S>
0060 struct
0061 deduce_q2_default<Q,Q,S,false,false>
0062 {
0063 BOOST_QVM_STATIC_ASSERT(is_quat<Q>::value);
0064 typedef Q type;
0065 };
0066
0067 template <class A,class B,class S>
0068 struct
0069 deduce_q2_default<A,B,S,false,true>
0070 {
0071 BOOST_QVM_STATIC_ASSERT(is_quat<A>::value);
0072 typedef typename deduce_quat<A,S>::type type;
0073 };
0074
0075 template <class A,class B,class S>
0076 struct
0077 deduce_q2_default<A,B,S,true,false>
0078 {
0079 BOOST_QVM_STATIC_ASSERT(is_quat<B>::value);
0080 typedef typename deduce_quat<B,S>::type type;
0081 };
0082 }
0083
0084 template <class A,class B,class S=typename deduce_scalar<typename scalar<A>::type,typename scalar<B>::type>::type>
0085 struct
0086 deduce_quat2
0087 {
0088 BOOST_QVM_STATIC_ASSERT(is_quat<A>::value || is_quat<B>::value);
0089 typedef typename qvm_detail::deduce_q2_default<A,B,S>::type type;
0090 };
0091
0092 } }
0093
0094 #endif