| 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 | #if __cplusplus <= 199711L |
| 7 | |
| 8 | #include <iostream> |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | std::cout << "Test not applicable due to lack of C++11 support in the compiler" << std::endl; |
| 13 | return 0; |
| 14 | } |
| 15 | |
| 16 | #else |
| 17 | |
| 18 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER |
| 19 | # include BOOST_QVM_TEST_SINGLE_HEADER |
| 20 | #else |
| 21 | # include <boost/qvm/vec_operations.hpp> |
| 22 | #endif |
| 23 | |
| 24 | #include <boost/qvm/vec_traits_array.hpp> |
| 25 | #include <boost/core/lightweight_test.hpp> |
| 26 | |
| 27 | template <class T,class U> |
| 28 | struct same_type; |
| 29 | |
| 30 | template <class T> |
| 31 | struct |
| 32 | same_type<T,T> |
| 33 | { |
| 34 | }; |
| 35 | |
| 36 | int |
| 37 | main() |
| 38 | { |
| 39 | using namespace boost::qvm; |
| 40 | BOOST_QVM_STATIC_ASSERT((is_vec<std::array<int,3>>::value)); |
| 41 | BOOST_QVM_STATIC_ASSERT((is_vec<std::array<int const,3>>::value)); |
| 42 | BOOST_QVM_STATIC_ASSERT((is_vec<std::array<int,3> const>::value)); |
| 43 | BOOST_QVM_STATIC_ASSERT((is_vec<std::array<int const,3> const>::value)); |
| 44 | BOOST_QVM_STATIC_ASSERT((!is_vec<std::array<std::array<int,3>,3>>::value)); |
| 45 | BOOST_QVM_STATIC_ASSERT((!is_vec<std::array<std::array<std::array<int,3>,3>,3>>::value)); |
| 46 | BOOST_QVM_STATIC_ASSERT((vec_traits<std::array<int,3>>::dim==3)); |
| 47 | BOOST_QVM_STATIC_ASSERT((vec_traits<std::array<int const,3>>::dim==3)); |
| 48 | BOOST_QVM_STATIC_ASSERT((vec_traits<std::array<int,3> const>::dim==3)); |
| 49 | BOOST_QVM_STATIC_ASSERT((vec_traits<std::array<int const,3> const>::dim==3)); |
| 50 | same_type<vec_traits<std::array<int,3>>::scalar_type,int>(); |
| 51 | same_type<vec_traits<std::array<int const,3>>::scalar_type,int const>(); |
| 52 | same_type<vec_traits<std::array<int,3> const>::scalar_type,int>(); |
| 53 | same_type<vec_traits<std::array<int const,3> const>::scalar_type,int const>(); |
| 54 | same_type< vec<int,3>, deduce_vec<std::array<int,3>>::type >(); |
| 55 | same_type< vec<int const,3>, deduce_vec<std::array<int const,3>>::type >(); |
| 56 | same_type< vec<int,3>, deduce_vec<std::array<int,3> const>::type >(); |
| 57 | same_type< vec<int const,3>, deduce_vec<std::array<int const,3> const>::type >(); |
| 58 | std::array<int,3> arr1 = {0,1,2}; |
| 59 | std::array<int const,3> arr2 = {0,1,2}; |
| 60 | std::array<int,3> const arr3 = {0,1,2}; |
| 61 | std::array<int const,3> const arr4 = {0,1,2}; |
| 62 | BOOST_TEST((vec_traits<std::array<int,3>>::read_element<0>(arr1)==0)); |
| 63 | BOOST_TEST((vec_traits<std::array<int,3>>::read_element<1>(arr1)==1)); |
| 64 | BOOST_TEST((vec_traits<std::array<int,3>>::read_element<2>(arr1)==2)); |
| 65 | BOOST_TEST((vec_traits<std::array<int const,3>>::read_element<0>(arr2)==0)); |
| 66 | BOOST_TEST((vec_traits<std::array<int const,3>>::read_element<1>(arr2)==1)); |
| 67 | BOOST_TEST((vec_traits<std::array<int const,3>>::read_element<2>(arr2)==2)); |
| 68 | BOOST_TEST((vec_traits<std::array<int,3> const>::read_element<0>(arr3)==0)); |
| 69 | BOOST_TEST((vec_traits<std::array<int,3> const>::read_element<1>(arr3)==1)); |
| 70 | BOOST_TEST((vec_traits<std::array<int,3> const>::read_element<2>(arr3)==2)); |
| 71 | BOOST_TEST((vec_traits<std::array<int const,3> const>::read_element<0>(arr4)==0)); |
| 72 | BOOST_TEST((vec_traits<std::array<int const,3> const>::read_element<1>(arr4)==1)); |
| 73 | BOOST_TEST((vec_traits<std::array<int const,3> const>::read_element<2>(arr4)==2)); |
| 74 | BOOST_TEST((vec_traits<std::array<int,3>>::read_element_idx(0,arr1)==0)); |
| 75 | BOOST_TEST((vec_traits<std::array<int,3>>::read_element_idx(1,arr1)==1)); |
| 76 | BOOST_TEST((vec_traits<std::array<int,3>>::read_element_idx(2,arr1)==2)); |
| 77 | BOOST_TEST((vec_traits<std::array<int const,3>>::read_element_idx(0,arr2)==0)); |
| 78 | BOOST_TEST((vec_traits<std::array<int const,3>>::read_element_idx(1,arr2)==1)); |
| 79 | BOOST_TEST((vec_traits<std::array<int const,3>>::read_element_idx(2,arr2)==2)); |
| 80 | BOOST_TEST((vec_traits<std::array<int,3> const>::read_element_idx(0,arr3)==0)); |
| 81 | BOOST_TEST((vec_traits<std::array<int,3> const>::read_element_idx(1,arr3)==1)); |
| 82 | BOOST_TEST((vec_traits<std::array<int,3> const>::read_element_idx(2,arr3)==2)); |
| 83 | BOOST_TEST((vec_traits<std::array<int const,3> const>::read_element_idx(0,arr4)==0)); |
| 84 | BOOST_TEST((vec_traits<std::array<int const,3> const>::read_element_idx(1,arr4)==1)); |
| 85 | BOOST_TEST((vec_traits<std::array<int const,3> const>::read_element_idx(2,arr4)==2)); |
| 86 | BOOST_TEST((&vec_traits<std::array<int,3>>::write_element<0>(arr1)==&arr1[0])); |
| 87 | BOOST_TEST((&vec_traits<std::array<int,3>>::write_element<1>(arr1)==&arr1[1])); |
| 88 | BOOST_TEST((&vec_traits<std::array<int,3>>::write_element<2>(arr1)==&arr1[2])); |
| 89 | BOOST_TEST((&vec_traits<std::array<int,3>>::write_element_idx(0,arr1)==&arr1[0])); |
| 90 | BOOST_TEST((&vec_traits<std::array<int,3>>::write_element_idx(1,arr1)==&arr1[1])); |
| 91 | BOOST_TEST((&vec_traits<std::array<int,3>>::write_element_idx(2,arr1)==&arr1[2])); |
| 92 | return boost::report_errors(); |
| 93 | } |
| 94 | |
| 95 | #endif |
| 96 | |