#ifndef BOOST_QVM_QUAT_TRAITS #define BOOST_QVM_QUAT_TRAITS // 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 #include namespace boost { namespace qvm { template struct quat_traits { typedef void scalar_type; }; template struct is_quat { static bool const value = is_scalar::scalar_type>::value; }; namespace qvm_detail { template struct qtr_dispatch_yes { char x, y; }; } template class quat_write_element_ref { template static qvm_detail::qtr_dispatch_yes::scalar_type & (*)( U & ), &quat_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< quat_write_element_ref::value, void>::type write_quat_element( Q & q, typename quat_traits::scalar_type s ) { quat_traits::template write_element(q) = s; } template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< !quat_write_element_ref::value, void>::type write_quat_element( Q & q, typename quat_traits::scalar_type s ) { quat_traits::template write_element(q, s); } template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< quat_write_element_ref::value, void>::type write_quat_element_idx( int i, Q & q, typename quat_traits::scalar_type s ) { quat_traits::template write_element_idx(i, q) = s; } template BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL typename enable_if_c< !quat_write_element_ref::value, void>::type write_vec_element_idx( int i, Q & q, typename quat_traits::scalar_type s ) { quat_traits::template write_element_idx(i, q, s); } } } #endif