//Copyright (c) 2008-2016 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 UUID_E831FAD6B38F11DE8CECBF0D56D89593 #define UUID_E831FAD6B38F11DE8CECBF0D56D89593 #include #include #include #include namespace boost { namespace qvm { namespace qvm_detail { BOOST_QVM_INLINE_CRITICAL void const * get_null() { static int const obj=0; return &obj; } template struct swizzle_idx { static int const value=A; typedef Next next; }; template struct const_value { static BOOST_QVM_INLINE_TRIVIAL typename vec_traits::scalar_type value() { BOOST_QVM_ASSERT(0); return typename vec_traits::scalar_type(); } }; template struct const_value { static BOOST_QVM_INLINE_TRIVIAL typename vec_traits::scalar_type value() { return scalar_traits::scalar_type>::value(0); } }; template struct const_value { static BOOST_QVM_INLINE_TRIVIAL typename vec_traits::scalar_type value() { return scalar_traits::scalar_type>::value(1); } }; template struct neg_zero; template struct neg_zero { static int const value=0; }; template struct neg_zero { static int const value=Index; }; template struct swizzle { static int const value=swizzle::value; }; template struct swizzle { static int const value=SwizzleList::value; }; template struct swizzle; template struct swizzle_list_length { static int const value=swizzle_list_length::value; }; template struct swizzle_list_length { static int const value=C; }; template struct validate_swizzle_list { static bool const value = ((SwizzleList::value)::value; }; template struct validate_swizzle_list { static bool const value=true; }; template class sw_ { sw_( sw_ const & ); sw_ & operator=( sw_ const & ); ~sw_(); BOOST_QVM_STATIC_ASSERT((validate_swizzle_list::dim>::value)); public: template BOOST_QVM_INLINE_TRIVIAL sw_ & operator=( T const & x ) { assign(*this,x); return *this; } template BOOST_QVM_INLINE_TRIVIAL operator R() const { R r; assign(r,*this); return r; } }; template class sw01_ { sw01_( sw01_ const & ); sw01_ & operator=( sw01_ const & ); ~sw01_(); public: template BOOST_QVM_INLINE_TRIVIAL operator R() const { R r; assign(r,*this); return r; } }; template class sws_ { sws_( sws_ const & ); sws_ & operator=( sws_ const & ); ~sws_(); BOOST_QVM_STATIC_ASSERT((validate_swizzle_list::value)); public: template BOOST_QVM_INLINE_TRIVIAL operator R() const { R r; assign(r,*this); return r; } }; } template struct vec_traits > { typedef qvm_detail::sw_ this_vector; typedef typename vec_traits::scalar_type scalar_type; static int const dim=qvm_detail::swizzle_list_length::value; template static BOOST_QVM_INLINE_CRITICAL scalar_type read_element( this_vector const & x ) { BOOST_QVM_STATIC_ASSERT(I>=0); BOOST_QVM_STATIC_ASSERT(I::value; BOOST_QVM_STATIC_ASSERT(idx::dim); return idx>=0? vec_traits::template read_element::value>(reinterpret_cast(x)) : qvm_detail::const_value::value(); } template static BOOST_QVM_INLINE_CRITICAL scalar_type & write_element( this_vector & x ) { BOOST_QVM_STATIC_ASSERT(I>=0); BOOST_QVM_STATIC_ASSERT(I::value; BOOST_QVM_STATIC_ASSERT(idx>=0); BOOST_QVM_STATIC_ASSERT(idx::dim); return vec_traits::template write_element(reinterpret_cast(x)); } }; template struct vec_traits > { typedef qvm_detail::sw01_ this_vector; typedef int scalar_type; static int const dim=qvm_detail::swizzle_list_length::value; template static BOOST_QVM_INLINE_CRITICAL scalar_type read_element( this_vector const & ) { BOOST_QVM_STATIC_ASSERT(I>=0); BOOST_QVM_STATIC_ASSERT(I::value; BOOST_QVM_STATIC_ASSERT(idx<0); return qvm_detail::const_value::value(); } }; template struct vec_traits > { typedef qvm_detail::sws_ this_vector; typedef OriginalScalar scalar_type; static int const dim=qvm_detail::swizzle_list_length::value; template static BOOST_QVM_INLINE_CRITICAL scalar_type read_element( this_vector const & x ) { BOOST_QVM_STATIC_ASSERT(I>=0); BOOST_QVM_STATIC_ASSERT(I::value; BOOST_QVM_STATIC_ASSERT(idx<1); return idx==0? reinterpret_cast(x) : qvm_detail::const_value::value(); } template static BOOST_QVM_INLINE_CRITICAL scalar_type & write_element( this_vector & x ) { BOOST_QVM_STATIC_ASSERT(I>=0); BOOST_QVM_STATIC_ASSERT(I::value; BOOST_QVM_STATIC_ASSERT(idx==0); return reinterpret_cast(x); } }; template struct deduce_vec,D> { typedef vec::scalar_type,D> type; }; template struct deduce_vec2,qvm_detail::sw_,D> { typedef vec::scalar_type,D> type; }; template struct deduce_vec,D> { typedef vec type; }; template struct deduce_vec2,qvm_detail::sws_,D> { typedef vec type; }; } } #endif