]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | #ifndef BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED |
2 | #define BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED | |
92f5a8d4 | 3 | |
1e59de90 | 4 | // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. |
92f5a8d4 | 5 | |
1e59de90 TL |
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) | |
92f5a8d4 TL |
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/inline.hpp> | |
13 | ||
1e59de90 TL |
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 | ||
92f5a8d4 | 29 | namespace |
1e59de90 | 30 | qvm_detail |
92f5a8d4 | 31 | { |
1e59de90 TL |
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 | |
92f5a8d4 | 39 | { |
1e59de90 TL |
40 | typedef void type; |
41 | }; | |
92f5a8d4 | 42 | |
1e59de90 TL |
43 | template <class A> |
44 | struct | |
45 | scalar_impl<A,false,false,false,true> | |
46 | { | |
47 | typedef A type; | |
48 | }; | |
92f5a8d4 | 49 | |
1e59de90 TL |
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 | }; | |
92f5a8d4 | 56 | |
1e59de90 TL |
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 | }; | |
92f5a8d4 | 63 | |
1e59de90 TL |
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 | } | |
92f5a8d4 | 71 | |
1e59de90 TL |
72 | template <class A> |
73 | struct | |
74 | scalar | |
75 | { | |
76 | typedef typename qvm_detail::scalar_impl<A>::type type; | |
77 | }; | |
92f5a8d4 | 78 | |
1e59de90 | 79 | } } |
92f5a8d4 TL |
80 | |
81 | #endif |