/*============================================================================= 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_COMPOST_FORMATS_AS_REAL_HPP #define SPROUT_COMPOST_FORMATS_AS_REAL_HPP #include #include #include #include #include namespace sprout { namespace compost { // // to_real_value // struct to_real_value { public: template SPROUT_CONSTEXPR decltype(real(std::declval())) operator()(Complex const& x) const { return real(x); } }; namespace formats { // // as_real_forwarder // class as_real_forwarder {}; // // as_real // namespace { SPROUT_STATIC_CONSTEXPR sprout::compost::formats::as_real_forwarder as_real = {}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR auto operator|(Range&& lhs, sprout::compost::formats::as_real_forwarder const&) -> decltype( sprout::forward(lhs) | sprout::adaptors::transformed(sprout::compost::to_real_value()) ) { return sprout::forward(lhs) | sprout::adaptors::transformed(sprout::compost::to_real_value()) ; } } // namespace formats using sprout::compost::formats::as_real; } // namespace compost } // namespace sprout #endif // #ifndef SPROUT_COMPOST_FORMATS_AS_REAL_HPP