Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:04:00

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