Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:59:03

0001 #ifndef BOOST_QVM_DEDUCE_VEC_HPP_INCLUDED
0002 #define BOOST_QVM_DEDUCE_VEC_HPP_INCLUDED
0003 
0004 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
0005 
0006 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0007 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #include <boost/qvm/deduce_scalar.hpp>
0010 #include <boost/qvm/vec_traits.hpp>
0011 #include <boost/qvm/static_assert.hpp>
0012 
0013 namespace boost { namespace qvm {
0014 
0015 template <class T,int D>
0016 struct vec;
0017 
0018 namespace
0019 qvm_detail
0020     {
0021     template <class V,int D,class S,
0022         int VD=vec_traits<V>::dim,
0023         class VS=typename vec_traits<V>::scalar_type>
0024     struct
0025     deduce_v_default
0026         {
0027         BOOST_QVM_STATIC_ASSERT(is_vec<V>::value);
0028         typedef vec<typename vec_traits<V>::scalar_type,D> type;
0029         };
0030 
0031     template <class V,int D,class S>
0032     struct
0033     deduce_v_default<V,D,S,D,S>
0034         {
0035         BOOST_QVM_STATIC_ASSERT(is_vec<V>::value);
0036         typedef V type;
0037         };
0038     }
0039 
0040 template <class V,int D=vec_traits<V>::dim,class S=typename vec_traits<V>::scalar_type>
0041 struct
0042 deduce_vec
0043     {
0044     BOOST_QVM_STATIC_ASSERT(is_vec<V>::value);
0045     typedef typename qvm_detail::deduce_v_default<V,D,S>::type type;
0046     };
0047 
0048 namespace
0049 qvm_detail
0050     {
0051     template <class A,class B,int D,class S,
0052         bool IsScalarA=is_scalar<A>::value,
0053         bool IsScalarB=is_scalar<B>::value>
0054     struct
0055     deduce_v2_default
0056         {
0057         typedef vec<S,D> type;
0058         };
0059 
0060     template <class V,int D,class S>
0061     struct
0062     deduce_v2_default<V,V,D,S,false,false>
0063         {
0064         BOOST_QVM_STATIC_ASSERT(is_vec<V>::value);
0065         typedef V type;
0066         };
0067 
0068     template <class A,class B,int D,class S>
0069     struct
0070     deduce_v2_default<A,B,D,S,false,true>
0071         {
0072         BOOST_QVM_STATIC_ASSERT(is_vec<A>::value);
0073         typedef typename deduce_vec<A,D,S>::type type;
0074         };
0075 
0076     template <class A,class B,int D,class S>
0077     struct
0078     deduce_v2_default<A,B,D,S,true,false>
0079         {
0080         BOOST_QVM_STATIC_ASSERT(is_vec<B>::value);
0081         typedef typename deduce_vec<B,D,S>::type type;
0082         };
0083     }
0084 
0085 template <class A,class B,int D,class S=typename deduce_scalar<typename scalar<A>::type,typename scalar<B>::type>::type>
0086 struct
0087 deduce_vec2
0088     {
0089     BOOST_QVM_STATIC_ASSERT(is_vec<A>::value || is_vec<B>::value);
0090     typedef typename qvm_detail::deduce_v2_default<A,B,D,S>::type type;
0091     };
0092 
0093 } }
0094 
0095 #endif