#ifndef BOOST_QVM_VEC_TRAITS_DEFAULTS_HPP_INCLUDED #define BOOST_QVM_VEC_TRAITS_DEFAULTS_HPP_INCLUDED // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include namespace boost { namespace qvm { template struct vec_traits; namespace qvm_detail { template struct vector_w { template static BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename vec_traits::scalar_type & write_element_idx( int i, A & a ) { return I==i? vec_traits::template write_element(a) : vector_w::write_element_idx(i,a); } }; template struct vector_w { template static BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename vec_traits::scalar_type & write_element_idx( int, A & a ) { BOOST_QVM_ASSERT(0); return vec_traits::template write_element<0>(a); } }; } template struct vec_traits_defaults { typedef VecType vec_type; typedef ScalarType scalar_type; static int const dim=Dim; template static BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL scalar_type read_element( vec_type const & x ) { return vec_traits::template write_element(const_cast(x)); } static BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL scalar_type read_element_idx( int i, vec_type const & x ) { return vec_traits::write_element_idx(i,const_cast(x)); } protected: static BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL scalar_type & write_element_idx( int i, vec_type & m ) { return qvm_detail::vector_w<0,vec_traits::dim>::write_element_idx(i,m); } }; } } #endif