// 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) #ifndef BOOST_QVM_VEC_TRAITS_HPP_INCLUDED #define BOOST_QVM_VEC_TRAITS_HPP_INCLUDED #include #include #include namespace boost { namespace qvm { template struct vec_traits { static int const dim=0; typedef void scalar_type; }; template struct is_vec { static bool const value = is_scalar::scalar_type>::value && vec_traits::dim>0; }; namespace qvm_detail { template struct vtr_dispatch_yes { char x, y; }; } template class vec_write_element_ref { template static qvm_detail::vtr_dispatch_yes::scalar_type & (*)( U & ), &vec_traits::template write_element<0> > check(int); template static char check(long); public: static bool const value = sizeof(check(0)) > 1; }; template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< vec_write_element_ref::value, void>::type write_vec_element( V & v, typename vec_traits::scalar_type s ) { vec_traits::template write_element(v) = s; } template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< !vec_write_element_ref::value, void>::type write_vec_element( V & v, typename vec_traits::scalar_type s ) { vec_traits::template write_element(v, s); } template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< vec_write_element_ref::value, void>::type write_vec_element_idx( int i, V & v, typename vec_traits::scalar_type s ) { vec_traits::write_element_idx(i, v) = s; } template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< !vec_write_element_ref::value, void>::type write_vec_element_idx( int i, V & v, typename vec_traits::scalar_type s ) { vec_traits::write_element_idx(i, v, s); } } } #endif