| 1 | // Copyright 2008-2022 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 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER |
| 7 | # include BOOST_QVM_TEST_SINGLE_HEADER |
| 8 | #else |
| 9 | # include <boost/qvm/vec_operations.hpp> |
| 10 | # include <boost/qvm/vec.hpp> |
| 11 | #endif |
| 12 | |
| 13 | #include "test_qvm_vector.hpp" |
| 14 | |
| 15 | namespace |
| 16 | { |
| 17 | template <class T,class U> |
| 18 | struct same_type; |
| 19 | |
| 20 | template <class T> |
| 21 | struct |
| 22 | same_type<T,T> |
| 23 | { |
| 24 | }; |
| 25 | |
| 26 | template <class T,class U> |
| 27 | void |
| 28 | check_deduction( T const &, U const & ) |
| 29 | { |
| 30 | same_type<T,typename boost::qvm::deduce_vec<U>::type>(); |
| 31 | } |
| 32 | |
| 33 | template <int Dim> |
| 34 | void |
| 35 | test() |
| 36 | { |
| 37 | using namespace boost::qvm; |
| 38 | test_qvm::vector<V1,Dim> v1=zero_vec<float,Dim>(); |
| 39 | for( int i=0; i!=Dim; ++i ) |
| 40 | BOOST_TEST(!v1.a[i]); |
| 41 | test_qvm::vector<V2,Dim> v2(42,1); |
| 42 | set_zero(v2); |
| 43 | for( int i=0; i!=Dim; ++i ) |
| 44 | BOOST_TEST(!v2.a[i]); |
| 45 | check_deduction(vec<float,Dim>(),zero_vec<float,Dim>()); |
| 46 | check_deduction(vec<int,Dim>(),zero_vec<int,Dim>()); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | int |
| 51 | main() |
| 52 | { |
| 53 | test<2>(); |
| 54 | test<3>(); |
| 55 | test<4>(); |
| 56 | test<5>(); |
| 57 | return boost::report_errors(); |
| 58 | } |
| 59 | |