1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/compost/effects/fuzzed.hpp

87 lines
2.5 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2014-01-08 07:48:12 +00:00
Copyright (c) 2011-2014 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
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)
=============================================================================*/
2012-11-17 09:44:24 +00:00
#ifndef SPROUT_COMPOST_EFFECTS_FUZZED_HPP
#define SPROUT_COMPOST_EFFECTS_FUZZED_HPP
2012-11-09 13:33:11 +00:00
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/range/adaptor/transformed.hpp>
2012-11-17 09:44:24 +00:00
#include <sprout/compost/effects/rectified.hpp>
#include <sprout/compost/effects/distorted.hpp>
2012-11-09 13:33:11 +00:00
namespace sprout {
namespace compost {
namespace effects {
//
// fuzz_holder
//
template<typename T>
class fuzz_holder {
public:
typedef T value_type;
private:
value_type gain_;
value_type level_;
public:
2014-01-13 15:18:06 +00:00
SPROUT_CONSTEXPR fuzz_holder() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL
2012-11-09 13:33:11 +00:00
fuzz_holder(fuzz_holder const&) = default;
SPROUT_CONSTEXPR fuzz_holder(value_type const& gain, value_type const& level)
2013-02-26 01:43:27 +00:00
: gain_(gain), level_(level)
2012-11-09 13:33:11 +00:00
{}
SPROUT_CONSTEXPR value_type const& gain() const {
return gain_;
}
SPROUT_CONSTEXPR value_type const& level() const {
return level_;
}
};
//
// fuzzed_forwarder
//
class fuzzed_forwarder {
public:
template<typename T>
SPROUT_CONSTEXPR sprout::compost::effects::fuzz_holder<T>
2013-02-19 17:23:20 +00:00
operator()(T const& gain, T const& level) const {
2012-11-09 13:33:11 +00:00
return sprout::compost::effects::fuzz_holder<T>(gain, level);
}
};
//
// fuzzed
//
namespace {
2012-12-17 14:10:23 +00:00
SPROUT_STATIC_CONSTEXPR sprout::compost::effects::fuzzed_forwarder fuzzed = {};
2012-11-09 13:33:11 +00:00
} // anonymous-namespace
//
// operator|
//
template<typename Range, typename T>
inline SPROUT_CONSTEXPR auto
operator|(Range&& lhs, sprout::compost::effects::fuzz_holder<T> const& rhs)
-> decltype(
sprout::forward<Range>(lhs)
| sprout::compost::effects::rectified
| sprout::compost::effects::distorted(rhs.gain(), rhs.level())
)
{
return sprout::forward<Range>(lhs)
| sprout::compost::effects::rectified
| sprout::compost::effects::distorted(rhs.gain(), rhs.level())
;
}
} // namespace effects
using sprout::compost::effects::fuzzed;
2012-11-09 13:33:11 +00:00
} // namespace compost
} // namespace sprout
2012-11-17 09:44:24 +00:00
#endif // #ifndef SPROUT_COMPOST_EFFECTS_FUZZED_HPP