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 BOOST_QVM_02C176D6B3AB11DE979F9A0D56D89593 7 #define BOOST_QVM_02C176D6B3AB11DE979F9A0D56D89593 8 9 #include <boost/qvm/vec_traits_defaults.hpp> 10 #include <boost/qvm/deduce_vec.hpp> 11 #include <boost/qvm/assert.hpp> 12 #include "test_qvm.hpp" 13 14 namespace 15 test_qvm 16 { 17 template <class Tag,int Dim,class T=float> 18 struct 19 vector 20 { 21 T a[Dim]; 22 mutable T b[Dim]; 23 24 explicit vectortest_qvm::vector25 vector( T start=T(0), T step=T(0) ) 26 { 27 for( int i=0; i!=Dim; ++i,start+=step ) 28 a[i]=b[i]=start; 29 } 30 }; 31 32 template <int Dim,class Tag1,class T1,class Tag2,class T2> 33 void dump_ab(vector<Tag1,Dim,T1> const & a,vector<Tag2,Dim,T2> const & b)34 dump_ab( vector<Tag1,Dim,T1> const & a, vector<Tag2,Dim,T2> const & b ) 35 { 36 detail::dump_ab(a.a,b.a); 37 } 38 } 39 40 namespace 41 boost 42 { 43 namespace 44 qvm 45 { 46 template <class Tag,int Dim,class T> 47 struct 48 vec_traits< test_qvm::vector<Tag,Dim,T> >: 49 vec_traits_defaults<test_qvm::vector<Tag,Dim,T>,T,Dim> 50 { 51 typedef vec_traits_defaults<test_qvm::vector<Tag,Dim,T>,T,Dim>base; 52 53 template <int I> 54 static 55 typename base::scalar_type & write_elementboost::qvm::vec_traits56 write_element( typename base::vec_type & m ) 57 { 58 BOOST_QVM_STATIC_ASSERT(I>=0); 59 BOOST_QVM_STATIC_ASSERT(I<Dim); 60 return m.a[I]; 61 } 62 63 using base::write_element_idx; 64 }; 65 66 template <class Tag,class T,int D1,int D2,int Dim> 67 struct 68 deduce_vec2<test_qvm::vector<Tag,D1,T>,test_qvm::vector<Tag,D2,T>,Dim> 69 { 70 typedef test_qvm::vector<Tag,Dim,T> type; 71 }; 72 } 73 } 74 75 namespace 76 { 77 struct V1; 78 struct V2; 79 struct V3; 80 } 81 82 #endif 83