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-05-31 13:28:58 +00:00
|
|
|
#ifndef SPROUT_TUPLE_FUSED_HPP
|
|
|
|
#define SPROUT_TUPLE_FUSED_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2013-02-07 15:49:47 +00:00
|
|
|
#include <sprout/tuple/tuple/tuple.hpp>
|
2014-12-14 03:59:51 +00:00
|
|
|
#include <sprout/tuple/apply.hpp>
|
2012-05-31 13:28:58 +00:00
|
|
|
#include <sprout/utility/forward.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace tuples {
|
|
|
|
//
|
|
|
|
// fused
|
|
|
|
//
|
|
|
|
template<typename F>
|
|
|
|
class fused {
|
|
|
|
public:
|
|
|
|
typedef F functor_type;
|
2012-07-18 13:15:59 +00:00
|
|
|
public:
|
|
|
|
template<typename Tuple>
|
|
|
|
struct result
|
2014-12-14 03:59:51 +00:00
|
|
|
: public sprout::tuples::apply_result<functor_type const&, Tuple>
|
2012-07-18 13:15:59 +00:00
|
|
|
{};
|
2012-05-31 13:28:58 +00:00
|
|
|
private:
|
|
|
|
functor_type f_;
|
|
|
|
public:
|
2014-01-13 15:18:06 +00:00
|
|
|
SPROUT_CONSTEXPR fused() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL
|
2012-05-31 13:28:58 +00:00
|
|
|
fused(fused const&) = default;
|
|
|
|
explicit SPROUT_CONSTEXPR fused(F f)
|
|
|
|
: f_(f)
|
|
|
|
{}
|
|
|
|
SPROUT_CONSTEXPR functor_type functor() const {
|
|
|
|
return f_;
|
|
|
|
}
|
|
|
|
template<typename Tuple>
|
2012-07-18 13:15:59 +00:00
|
|
|
SPROUT_CONSTEXPR typename result<Tuple>::type
|
|
|
|
operator()(Tuple&& t) const {
|
2014-12-14 03:59:51 +00:00
|
|
|
return sprout::tuples::apply(f_, SPROUT_FORWARD(Tuple, t));
|
2012-05-31 13:28:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// make_fused
|
|
|
|
//
|
|
|
|
template<typename F>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::tuples::fused<F>
|
|
|
|
make_fused(F const& f) {
|
|
|
|
return sprout::tuples::fused<F>(f);
|
|
|
|
}
|
|
|
|
} // namespace tuples
|
|
|
|
|
|
|
|
using sprout::tuples::fused;
|
|
|
|
using sprout::tuples::make_fused;
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_TUPLE_FUSED_HPP
|