Files
boost_fusion/include/boost/fusion/functional/adapter/fused.hpp

85 lines
2.4 KiB
C++
Raw Normal View History

2007-02-15 22:41:45 +00:00
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_HPP_INCLUDED)
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_HPP_INCLUDED
#include <boost/type_traits/add_reference.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/functional/invocation/invoke.hpp>
namespace boost { namespace fusion
{
template <typename Function> class fused;
//----- ---- --- -- - - - -
template <typename Function>
class fused
{
Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t;
public:
inline explicit fused(func_const_fwd_t f = Function())
: fnc_transformed(f)
{ }
template <class Seq>
inline typename result_of::invoke<func_const_fwd_t,Seq const>::type
2007-02-15 22:41:45 +00:00
operator()(Seq const & s) const
{
return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
2007-02-15 22:41:45 +00:00
}
template <class Seq>
inline typename result_of::invoke<func_fwd_t,Seq const>::type
2007-02-15 22:41:45 +00:00
operator()(Seq const & s)
{
return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
2007-02-15 22:41:45 +00:00
}
template <class Seq>
inline typename result_of::invoke<func_const_fwd_t,Seq>::type
2007-02-15 22:41:45 +00:00
operator()(Seq & s) const
{
return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
2007-02-15 22:41:45 +00:00
}
template <class Seq>
inline typename result_of::invoke<func_fwd_t,Seq>::type
2007-02-15 22:41:45 +00:00
operator()(Seq & s)
{
return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
2007-02-15 22:41:45 +00:00
}
template <typename Sig>
struct result
{ };
template <class Self, class Seq>
struct result< Self const (Seq) >
: result_of::invoke<func_const_fwd_t,Seq>
{ };
template <class Self, class Seq>
struct result< Self(Seq) >
: result_of::invoke<func_fwd_t,Seq>
2007-02-15 22:41:45 +00:00
{ };
2007-02-15 22:41:45 +00:00
};
}}
#endif