1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

add adaptors::blanked

This commit is contained in:
bolero-MURAKAMI 2012-11-17 18:44:24 +09:00
parent e286c9bc6b
commit ded2da84ea
27 changed files with 350 additions and 349 deletions

View file

@ -0,0 +1,66 @@
#ifndef SPROUT_COMPOST_EFFECTS_RECTIFIED_HPP
#define SPROUT_COMPOST_EFFECTS_RECTIFIED_HPP
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/range/adaptor/transformed.hpp>
namespace sprout {
namespace compost {
//
// rectify_value
//
template<typename T = void>
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<void> {
public:
template<typename T>
SPROUT_CONSTEXPR T
operator()(T const& x) const {
return sprout::compost::rectify_value<T>()(x);
}
};
namespace effects {
//
// rectified_forwarder
//
class rectified_forwarder {};
//
// rectified
//
namespace {
SPROUT_STATIC_CONSTEXPR sprout::compost::effects::rectified_forwarder rectified{};
} // anonymous-namespace
//
// operator|
//
template<typename Range>
inline SPROUT_CONSTEXPR auto
operator|(Range&& lhs, sprout::compost::effects::rectified_forwarder const& rhs)
-> decltype(
sprout::forward<Range>(lhs)
| sprout::adaptors::transformed(sprout::compost::rectify_value<>())
)
{
return sprout::forward<Range>(lhs)
| sprout::adaptors::transformed(sprout::compost::rectify_value<>())
;
}
} // namespace effects
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_EFFECTS_RECTIFIED_HPP