| 1 | #ifndef BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED |
| 2 | #define BOOST_QVM_SCALAR_TRAITS_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/quat_traits.hpp> |
| 10 | #include <boost/qvm/vec_traits.hpp> |
| 11 | #include <boost/qvm/mat_traits.hpp> |
| 12 | #include <boost/qvm/config.hpp> |
| 13 | |
| 14 | namespace boost { namespace qvm { |
| 15 | |
| 16 | template <class Scalar> |
| 17 | struct |
| 18 | scalar_traits |
| 19 | { |
| 20 | static |
| 21 | BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL |
| 22 | Scalar |
| 23 | value( int v ) |
| 24 | { |
| 25 | return Scalar(v); |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | namespace |
| 30 | qvm_detail |
| 31 | { |
| 32 | template <class A, |
| 33 | bool IsQ=is_quat<A>::value, |
| 34 | bool IsV=is_vec<A>::value, |
| 35 | bool IsM=is_mat<A>::value, |
| 36 | bool IsS=is_scalar<A>::value> |
| 37 | struct |
| 38 | scalar_impl |
| 39 | { |
| 40 | typedef void type; |
| 41 | }; |
| 42 | |
| 43 | template <class A> |
| 44 | struct |
| 45 | scalar_impl<A,false,false,false,true> |
| 46 | { |
| 47 | typedef A type; |
| 48 | }; |
| 49 | |
| 50 | template <class A> |
| 51 | struct |
| 52 | scalar_impl<A,false,false,true,false> |
| 53 | { |
| 54 | typedef typename mat_traits<A>::scalar_type type; |
| 55 | }; |
| 56 | |
| 57 | template <class A> |
| 58 | struct |
| 59 | scalar_impl<A,false,true,false,false> |
| 60 | { |
| 61 | typedef typename vec_traits<A>::scalar_type type; |
| 62 | }; |
| 63 | |
| 64 | template <class A> |
| 65 | struct |
| 66 | scalar_impl<A,true,false,false,false> |
| 67 | { |
| 68 | typedef typename quat_traits<A>::scalar_type type; |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | template <class A> |
| 73 | struct |
| 74 | scalar |
| 75 | { |
| 76 | typedef typename qvm_detail::scalar_impl<A>::type type; |
| 77 | }; |
| 78 | |
| 79 | } } |
| 80 | |
| 81 | #endif |
| 82 | |