/*============================================================================= Copyright (c) 2011-2014 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_COMPLEX_TUPLE_HPP #define SPROUT_COMPLEX_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::complex > : public sprout::identity {}; template struct tuple_element_impl<1, sprout::complex > : public sprout::identity {}; template struct get_impl; template struct get_impl<0, sprout::complex > { public: SPROUT_CONSTEXPR T& operator()(sprout::complex& t) const { return t.real(); } SPROUT_CONSTEXPR T const& operator()(sprout::complex const& t) const { return t.real(); } }; template struct get_impl<1, sprout::complex > { public: SPROUT_CONSTEXPR T& operator()(sprout::complex& t) const { return t.imag(); } SPROUT_CONSTEXPR T const& operator()(sprout::complex const& t) const { return t.imag(); } }; } // 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::complex& t) SPROUT_NOEXCEPT { static_assert(I < 2, "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::complex const& t) SPROUT_NOEXCEPT { static_assert(I < 2, "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::complex&& t) SPROUT_NOEXCEPT { return sprout::move(sprout::tuples::get(t)); } } // namespace sprout #endif // #ifndef SPROUT_COMPLEX_TUPLE_HPP