]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. |
2 | ||
3 | //Distributed under the Boost Software License, Version 1.0. (See accompanying | |
4 | //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #ifndef UUID_57E1C032B9F311DEB7D9BAFE55D89593 | |
7 | #define UUID_57E1C032B9F311DEB7D9BAFE55D89593 | |
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 | ||
14 | namespace | |
15 | boost | |
16 | { | |
17 | namespace | |
18 | qvm | |
19 | { | |
20 | template <class Scalar> | |
21 | struct | |
22 | scalar_traits | |
23 | { | |
24 | static | |
25 | BOOST_QVM_INLINE_CRITICAL | |
26 | Scalar | |
27 | value( int v ) | |
28 | { | |
29 | return Scalar(v); | |
30 | } | |
31 | }; | |
32 | ||
33 | template <class T> | |
34 | struct | |
35 | is_scalar | |
36 | { | |
37 | static bool const value=false; | |
38 | }; | |
39 | template <> struct is_scalar<char> { static bool const value=true; }; | |
40 | template <> struct is_scalar<signed char> { static bool const value=true; }; | |
41 | template <> struct is_scalar<unsigned char> { static bool const value=true; }; | |
42 | template <> struct is_scalar<signed short> { static bool const value=true; }; | |
43 | template <> struct is_scalar<unsigned short> { static bool const value=true; }; | |
44 | template <> struct is_scalar<signed int> { static bool const value=true; }; | |
45 | template <> struct is_scalar<unsigned int> { static bool const value=true; }; | |
46 | template <> struct is_scalar<signed long> { static bool const value=true; }; | |
47 | template <> struct is_scalar<unsigned long> { static bool const value=true; }; | |
48 | template <> struct is_scalar<float> { static bool const value=true; }; | |
49 | template <> struct is_scalar<double> { static bool const value=true; }; | |
50 | ||
51 | namespace | |
52 | qvm_detail | |
53 | { | |
54 | template <class A,bool M=is_mat<A>::value,bool Q=is_quat<A>::value,bool V=is_vec<A>::value> | |
55 | struct | |
56 | scalar_impl | |
57 | { | |
58 | }; | |
59 | ||
60 | template <class A> | |
61 | struct | |
62 | scalar_impl<A,true,false,false> | |
63 | { | |
64 | typedef typename mat_traits<A>::scalar_type type; | |
65 | }; | |
66 | ||
67 | template <class A> | |
68 | struct | |
69 | scalar_impl<A,false,true,false> | |
70 | { | |
71 | typedef typename quat_traits<A>::scalar_type type; | |
72 | }; | |
73 | ||
74 | template <class A> | |
75 | struct | |
76 | scalar_impl<A,false,false,true> | |
77 | { | |
78 | typedef typename vec_traits<A>::scalar_type type; | |
79 | }; | |
80 | } | |
81 | ||
82 | template <class A> | |
83 | struct | |
84 | scalar | |
85 | { | |
86 | typedef typename qvm_detail::scalar_impl<A>::type type; | |
87 | }; | |
88 | } | |
89 | } | |
90 | ||
91 | #endif |