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_CHANGED_VOLUME_HPP
|
|
|
|
#define SPROUT_COMPOST_EFFECTS_CHANGED_VOLUME_HPP
|
2012-11-08 16:09:49 +00:00
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/functional/multiplies.hpp>
|
|
|
|
#include <sprout/functional/bind2nd.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
#include <sprout/range/adaptor/transformed.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace compost {
|
|
|
|
namespace effects {
|
|
|
|
//
|
|
|
|
// change_volume_holder
|
|
|
|
//
|
|
|
|
template<typename T>
|
|
|
|
class change_volume_holder {
|
|
|
|
public:
|
|
|
|
typedef T value_type;
|
|
|
|
private:
|
|
|
|
value_type value_;
|
|
|
|
public:
|
2014-01-13 15:18:06 +00:00
|
|
|
SPROUT_CONSTEXPR change_volume_holder() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL
|
2012-11-08 16:09:49 +00:00
|
|
|
change_volume_holder(change_volume_holder const&) = default;
|
|
|
|
explicit SPROUT_CONSTEXPR change_volume_holder(value_type const& value)
|
|
|
|
: value_(value)
|
|
|
|
{}
|
|
|
|
SPROUT_CONSTEXPR value_type const& value() const {
|
|
|
|
return value_;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// changed_volume_forwarder
|
|
|
|
//
|
|
|
|
class changed_volume_forwarder {
|
|
|
|
public:
|
|
|
|
template<typename T>
|
|
|
|
SPROUT_CONSTEXPR sprout::compost::effects::change_volume_holder<T>
|
2013-02-19 17:23:20 +00:00
|
|
|
operator()(T const& value) const {
|
2012-11-08 16:09:49 +00:00
|
|
|
return sprout::compost::effects::change_volume_holder<T>(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// changed_volume
|
|
|
|
//
|
|
|
|
namespace {
|
2012-12-17 14:10:23 +00:00
|
|
|
SPROUT_STATIC_CONSTEXPR sprout::compost::effects::changed_volume_forwarder changed_volume = {};
|
2012-11-08 16:09:49 +00:00
|
|
|
} // anonymous-namespace
|
|
|
|
|
|
|
|
//
|
|
|
|
// operator|
|
|
|
|
//
|
|
|
|
template<typename Range, typename T>
|
|
|
|
inline SPROUT_CONSTEXPR auto
|
|
|
|
operator|(Range&& lhs, sprout::compost::effects::change_volume_holder<T> const& rhs)
|
|
|
|
-> decltype(
|
|
|
|
sprout::forward<Range>(lhs)
|
|
|
|
| sprout::adaptors::transformed(sprout::bind2nd(sprout::multiplies<>(), rhs.value()))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::forward<Range>(lhs)
|
|
|
|
| sprout::adaptors::transformed(sprout::bind2nd(sprout::multiplies<>(), rhs.value()))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
} // namespace effects
|
2012-11-24 04:04:02 +00:00
|
|
|
|
|
|
|
using sprout::compost::effects::changed_volume;
|
2012-11-08 16:09:49 +00:00
|
|
|
} // namespace compost
|
|
|
|
} // namespace sprout
|
|
|
|
|
2012-11-17 09:44:24 +00:00
|
|
|
#endif // #ifndef SPROUT_COMPOST_EFFECTS_CHANGED_VOLUME_HPP
|