#ifndef SPROUT_COMPOST_EFFECTS_RECTIFIED_HPP #define SPROUT_COMPOST_EFFECTS_RECTIFIED_HPP #include #include #include namespace sprout { namespace compost { // // rectify_value // template struct rectify_value { public: typedef T argument_type; typedef T result_type; public: SPROUT_CONSTEXPR T operator()(T const& x) const { return x < 0 ? -x : x; } }; template<> struct rectify_value { public: template SPROUT_CONSTEXPR T operator()(T const& x) const { return sprout::compost::rectify_value()(x); } }; namespace effects { // // rectified_forwarder // class rectified_forwarder {}; // // rectified // namespace { SPROUT_STATIC_CONSTEXPR sprout::compost::effects::rectified_forwarder rectified = {}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR auto operator|(Range&& lhs, sprout::compost::effects::rectified_forwarder const& rhs) -> decltype( sprout::forward(lhs) | sprout::adaptors::transformed(sprout::compost::rectify_value<>()) ) { return sprout::forward(lhs) | sprout::adaptors::transformed(sprout::compost::rectify_value<>()) ; } } // namespace effects using sprout::compost::effects::rectified; } // namespace compost } // namespace sprout #endif // #ifndef SPROUT_COMPOST_EFFECTS_RECTIFIED_HPP