/*============================================================================= Copyright (c) 2011-2016 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout 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 SPROUT_MATH_QUATERNION_TUPLE_HPP #define SPROUT_MATH_QUATERNION_TUPLE_HPP #include #include #include #include #include #include #include namespace sprout { namespace tuples { namespace detail { template struct tuple_element_impl; template struct tuple_element_impl > : public sprout::detail::nil_base {}; template struct tuple_element_impl<0, sprout::math::quaternion > : public sprout::identity {}; template struct tuple_element_impl<1, sprout::math::quaternion > : public sprout::identity {}; template struct tuple_element_impl<2, sprout::math::quaternion > : public sprout::identity {}; template struct tuple_element_impl<3, sprout::math::quaternion > : public sprout::identity {}; template struct get_impl; template struct get_impl<0, sprout::math::quaternion > { public: SPROUT_CONSTEXPR T& operator()(sprout::math::quaternion& t) const { return t[0]; } SPROUT_CONSTEXPR T const& operator()(sprout::math::quaternion const& t) const { return t[0]; } }; template struct get_impl<1, sprout::math::quaternion > { public: SPROUT_CONSTEXPR T& operator()(sprout::math::quaternion& t) const { return t[1]; } SPROUT_CONSTEXPR T const& operator()(sprout::math::quaternion const& t) const { return t[1]; } }; template struct get_impl<2, sprout::math::quaternion > { public: SPROUT_CONSTEXPR T& operator()(sprout::math::quaternion& t) const { return t[2]; } SPROUT_CONSTEXPR T const& operator()(sprout::math::quaternion const& t) const { return t[2]; } }; template struct get_impl<3, sprout::math::quaternion > { public: SPROUT_CONSTEXPR T& operator()(sprout::math::quaternion& t) const { return t[3]; } SPROUT_CONSTEXPR T const& operator()(sprout::math::quaternion const& t) const { return t[3]; } }; } // namespace detail } // namespace tuples } // namespace sprout namespace std { #if defined(__clang__) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wmismatched-tags" #endif // // tuple_size // template struct tuple_size > : public sprout::integral_constant {}; // // tuple_element // template struct tuple_element > : public sprout::tuples::detail::tuple_element_impl > {}; #if defined(__clang__) # pragma clang diagnostic pop #endif } // namespace std namespace sprout { // // tuple_get // template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type& tuple_get(sprout::math::quaternion& t) SPROUT_NOEXCEPT { static_assert(I < 4, "tuple_get: index out of range"); return sprout::tuples::detail::get_impl >()(t); } template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type const& tuple_get(sprout::math::quaternion const& t) SPROUT_NOEXCEPT { static_assert(I < 4, "tuple_get: index out of range"); return sprout::tuples::detail::get_impl >()(t); } template inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type&& tuple_get(sprout::math::quaternion&& t) SPROUT_NOEXCEPT { return sprout::move(sprout::tuples::get(t)); } } // namespace sprout #endif // #ifndef SPROUT_MATH_QUATERNION_TUPLE_HPP