mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-29 20:17:32 +02:00
Merge pull request #62 from Flast/feature/sfinae-friendly-result_of
SFINAE-friendly result_of::invoke for develop
This commit is contained in:
@ -41,6 +41,7 @@
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/detail/enabler.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/front.hpp>
|
||||
@ -52,29 +53,10 @@
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
//~ namespace result_of
|
||||
//~ {
|
||||
//~ template <typename Function, class Sequence,
|
||||
//~ class Enable = unspecified>
|
||||
//~ struct invoke;
|
||||
//~ }
|
||||
|
||||
//~ template <typename Function, class Sequence>
|
||||
//~ inline typename result_of::invoke<Function, Sequence>::type
|
||||
//~ invoke(Function, Sequence &);
|
||||
|
||||
//~ template <typename Function, class Sequence>
|
||||
//~ inline typename result_of::invoke<Function, Sequence const>::type
|
||||
//~ invoke(Function, Sequence const &);
|
||||
|
||||
//----- ---- --- -- - - - -
|
||||
|
||||
namespace detail
|
||||
{
|
||||
namespace ft = function_types;
|
||||
|
||||
template <typename, typename T = void> struct always_void_ { typedef T type; };
|
||||
|
||||
template<
|
||||
typename Function, class Sequence,
|
||||
int N = result_of::size<Sequence>::value,
|
||||
@ -161,14 +143,20 @@ namespace boost { namespace fusion
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Function, class Sequence,
|
||||
class Enable =
|
||||
typename detail::invoke_impl<
|
||||
typename boost::remove_reference<Function>::type, Sequence
|
||||
>::result_type>
|
||||
struct invoke
|
||||
template <typename Function, class Sequence, typename = void>
|
||||
struct invoke;
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke<Function, Sequence,
|
||||
typename detail::enabler<
|
||||
typename detail::invoke_impl<
|
||||
typename boost::remove_reference<Function>::type, Sequence
|
||||
>::result_type
|
||||
>::type>
|
||||
{
|
||||
typedef Enable type;
|
||||
typedef typename detail::invoke_impl<
|
||||
typename boost::remove_reference<Function>::type, Sequence
|
||||
>::result_type type;
|
||||
};
|
||||
}
|
||||
|
||||
@ -207,7 +195,7 @@ namespace boost { namespace fusion
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_impl<Function,Sequence,N,false,true,
|
||||
typename always_void_<
|
||||
typename enabler<
|
||||
typename boost::result_of<Function(BOOST_PP_ENUM(N,M,~)) >::type
|
||||
>::type>
|
||||
{
|
||||
@ -301,7 +289,7 @@ namespace boost { namespace fusion
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_impl<Function,Sequence,N,false,false,
|
||||
typename always_void_<
|
||||
typename enabler<
|
||||
#define L(z,j,data) typename invoke_param_types<Sequence,N>::BOOST_PP_CAT(T, j)
|
||||
typename boost::result_of<Function(BOOST_PP_ENUM(N,L,~))>::type
|
||||
>::type>
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <boost/utility/result_of.hpp>
|
||||
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/detail/enabler.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
@ -34,29 +35,13 @@
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <class Function, class Sequence> struct invoke_function_object;
|
||||
}
|
||||
|
||||
template <class Function, class Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::invoke_function_object<Function, Sequence>::type
|
||||
invoke_function_object(Function, Sequence &);
|
||||
|
||||
template <class Function, class Sequence>
|
||||
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline typename result_of::invoke_function_object<Function, Sequence const
|
||||
>::type invoke_function_object(Function, Sequence const &);
|
||||
|
||||
//----- ---- --- -- - - - -
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<
|
||||
class Function, class Sequence,
|
||||
int N = result_of::size<Sequence>::value,
|
||||
bool RandomAccess = traits::is_random_access<Sequence>::value
|
||||
bool RandomAccess = traits::is_random_access<Sequence>::value,
|
||||
typename Enable = void
|
||||
>
|
||||
struct invoke_function_object_impl;
|
||||
|
||||
@ -72,7 +57,16 @@ namespace boost { namespace fusion
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <class Function, class Sequence> struct invoke_function_object
|
||||
template <class Function, class Sequence, class Enable = void>
|
||||
struct invoke_function_object;
|
||||
|
||||
template <class Function, class Sequence>
|
||||
struct invoke_function_object<Function, Sequence,
|
||||
typename detail::enabler<
|
||||
typename detail::invoke_function_object_impl<
|
||||
typename boost::remove_reference<Function>::type, Sequence
|
||||
>::result_type
|
||||
>::type>
|
||||
{
|
||||
typedef typename detail::invoke_function_object_impl<
|
||||
typename boost::remove_reference<Function>::type, Sequence
|
||||
@ -111,14 +105,18 @@ namespace boost { namespace fusion
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
#define M(z,j,data) \
|
||||
typename result_of::at_c<Sequence,j>::type
|
||||
|
||||
template <class Function, class Sequence>
|
||||
struct invoke_function_object_impl<Function,Sequence,N,true>
|
||||
struct invoke_function_object_impl<Function,Sequence,N,true,
|
||||
typename enabler<
|
||||
typename boost::result_of<Function (BOOST_PP_ENUM(N,M,~)) >::type
|
||||
>::type>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename boost::result_of<
|
||||
#define M(z,j,data) \
|
||||
typename result_of::at_c<Sequence,j>::type
|
||||
Function (BOOST_PP_ENUM(N,M,~)) >::type result_type;
|
||||
#undef M
|
||||
|
||||
@ -148,8 +146,15 @@ namespace boost { namespace fusion
|
||||
|
||||
};
|
||||
|
||||
#define M(z,j,data) \
|
||||
typename invoke_function_object_param_types<Sequence,N>::T ## j
|
||||
|
||||
template <class Function, class Sequence>
|
||||
struct invoke_function_object_impl<Function,Sequence,N,false>
|
||||
struct invoke_function_object_impl<Function,Sequence,N,false,
|
||||
typename enabler<
|
||||
typename boost::result_of<Function (BOOST_PP_ENUM(N,M,~)) >::type
|
||||
>::type>
|
||||
#undef M
|
||||
{
|
||||
private:
|
||||
typedef invoke_function_object_param_types<Sequence,N> seq;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <boost/function_types/parameter_types.hpp>
|
||||
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/detail/enabler.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/at.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
@ -38,24 +39,6 @@
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Function, class Sequence> struct invoke_procedure
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline void invoke_procedure(Function, Sequence &);
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline void invoke_procedure(Function, Sequence const &);
|
||||
|
||||
//----- ---- --- -- - - - -
|
||||
|
||||
namespace detail
|
||||
{
|
||||
namespace ft = function_types;
|
||||
@ -76,9 +59,27 @@ namespace boost { namespace fusion
|
||||
|
||||
}
|
||||
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Function, class Sequence, class Enable = void>
|
||||
struct invoke_procedure;
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_procedure<Function, Sequence,
|
||||
typename detail::enabler<
|
||||
typename detail::invoke_procedure_impl<
|
||||
typename boost::remove_reference<Function>::type,Sequence
|
||||
>::result_type
|
||||
>::type>
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline void invoke_procedure(Function f, Sequence & s)
|
||||
inline typename result_of::invoke_procedure<Function, Sequence>::type
|
||||
invoke_procedure(Function f, Sequence & s)
|
||||
{
|
||||
detail::invoke_procedure_impl<
|
||||
typename boost::remove_reference<Function>::type,Sequence
|
||||
@ -87,7 +88,8 @@ namespace boost { namespace fusion
|
||||
|
||||
template <typename Function, class Sequence>
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
inline void invoke_procedure(Function f, Sequence const & s)
|
||||
inline typename result_of::invoke_procedure<Function, Sequence const>::type
|
||||
invoke_procedure(Function f, Sequence const & s)
|
||||
{
|
||||
detail::invoke_procedure_impl<
|
||||
typename boost::remove_reference<Function>::type,Sequence const
|
||||
@ -110,6 +112,7 @@ namespace boost { namespace fusion
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_procedure_impl<Function,Sequence,N,false,true>
|
||||
{
|
||||
typedef void result_type;
|
||||
|
||||
#if N > 0
|
||||
|
||||
@ -135,6 +138,8 @@ namespace boost { namespace fusion
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_procedure_impl<Function,Sequence,N,true,true>
|
||||
{
|
||||
typedef void result_type;
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static inline void call(Function & f, Sequence & s)
|
||||
{
|
||||
@ -155,6 +160,7 @@ namespace boost { namespace fusion
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_procedure_impl<Function,Sequence,N,false,false>
|
||||
{
|
||||
typedef void result_type;
|
||||
|
||||
#if N > 0
|
||||
|
||||
@ -182,6 +188,8 @@ namespace boost { namespace fusion
|
||||
template <typename Function, class Sequence>
|
||||
struct invoke_procedure_impl<Function,Sequence,N,true,false>
|
||||
{
|
||||
typedef void result_type;
|
||||
|
||||
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
||||
static inline void call(Function & f, Sequence & s)
|
||||
{
|
||||
|
18
include/boost/fusion/support/detail/enabler.hpp
Normal file
18
include/boost/fusion/support/detail/enabler.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2015 Kohei Takahashi
|
||||
|
||||
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).
|
||||
==============================================================================*/
|
||||
#ifndef FUSION_DETAIL_ENABLER_02082015_163810
|
||||
#define FUSION_DETAIL_ENABLER_02082015_163810
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename, typename T = void>
|
||||
struct enabler { typedef T type; };
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
54
test/compile_time/sfinae_friendly.hpp
Normal file
54
test/compile_time/sfinae_friendly.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2015 Kohei Takahashi
|
||||
|
||||
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).
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef FUSION_TEST_SFINAE_FRIENDLY_HPP
|
||||
#define FUSION_TEST_SFINAE_FRIENDLY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/fusion/support/detail/result_of.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF)
|
||||
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace sfinae_friendly
|
||||
{
|
||||
template <typename, typename T = void> struct void_ { typedef T type; };
|
||||
|
||||
template <typename> struct arg_;
|
||||
template <typename R, typename T> struct arg_<R(T)> { typedef T type; };
|
||||
|
||||
template <typename Traits, typename = void>
|
||||
struct check
|
||||
: boost::mpl::true_ { };
|
||||
|
||||
template <typename Traits>
|
||||
struct check<Traits, typename void_<typename Traits::type>::type>
|
||||
: boost::mpl::false_ { };
|
||||
|
||||
struct unspecified {};
|
||||
typedef boost::fusion::vector<> v0;
|
||||
typedef boost::fusion::vector<unspecified> v1;
|
||||
typedef boost::fusion::vector<unspecified, unspecified> v2;
|
||||
typedef boost::fusion::vector<unspecified, unspecified, unspecified> v3;
|
||||
}
|
||||
|
||||
#define SFINAE_FRIENDLY_ASSERT(Traits) \
|
||||
BOOST_MPL_ASSERT((::sfinae_friendly::check<typename ::sfinae_friendly::arg_<void Traits>::type>))
|
||||
|
||||
#else
|
||||
|
||||
#define SFINAE_FRIENDLY_ASSERT(Traits) \
|
||||
BOOST_MPL_ASSERT((boost::mpl::true_))
|
||||
|
||||
#endif
|
||||
|
||||
#endif // FUSION_TEST_SFINAE_FRIENDLY_HPP
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/join.hpp>
|
||||
|
||||
#include "../compile_time/sfinae_friendly.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
@ -80,6 +82,11 @@ struct fobj
|
||||
int operator()(int i, object const &, object_nc &);
|
||||
int operator()(int i, object const &, object_nc &) const;
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj, sfinae_friendly::v0>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj, sfinae_friendly::v3>));
|
||||
|
||||
|
||||
struct nullary_fobj
|
||||
{
|
||||
@ -88,6 +95,10 @@ struct nullary_fobj
|
||||
int operator()() { return 0; }
|
||||
int operator()() const { return 1; }
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<nullary_fobj, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<nullary_fobj, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<nullary_fobj, sfinae_friendly::v3>));
|
||||
|
||||
|
||||
struct fobj_nc
|
||||
: boost::noncopyable
|
||||
@ -105,6 +116,11 @@ struct fobj_nc
|
||||
int operator()(int i) { return 14 + i; }
|
||||
int operator()(int i) const { return 15 + i; }
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj_nc, sfinae_friendly::v0>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj_nc, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj_nc, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<fobj_nc, sfinae_friendly::v3>));
|
||||
|
||||
|
||||
struct nullary_fobj_nc
|
||||
: boost::noncopyable
|
||||
@ -114,11 +130,34 @@ struct nullary_fobj_nc
|
||||
int operator()() { return 12; }
|
||||
int operator()() const { return 13; }
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<nullary_fobj_nc, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<nullary_fobj_nc, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<nullary_fobj_nc, sfinae_friendly::v3>));
|
||||
|
||||
|
||||
int nullary() { return 16; }
|
||||
int unary(int i) { return 17 + i; }
|
||||
int binary1(int i, object &) { return 18 + i; }
|
||||
int binary2(int i, object const &) { return 19 + i; }
|
||||
//FIXME
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(), sfinae_friendly::v3>));
|
||||
//
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int), sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int), sfinae_friendly::v3>));
|
||||
//
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object &), sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object &), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object &), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object &), sfinae_friendly::v3>));
|
||||
//
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object const &), sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object const &), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object const &), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<int(*)(int, object const &), sfinae_friendly::v3>));
|
||||
|
||||
typedef int (* func_ptr)(int);
|
||||
typedef int (* const c_func_ptr)(int);
|
||||
@ -182,28 +221,120 @@ members that;
|
||||
members_ptr spt_that(new members);
|
||||
const_members_ptr spt_that_c(new members);
|
||||
|
||||
fusion::single_view<members > sv_obj_ctx( that);
|
||||
fusion::single_view<members &> sv_ref_ctx( that);
|
||||
fusion::single_view<members *> sv_ptr_ctx(& that);
|
||||
fusion::single_view<members const > sv_obj_c_ctx( that);
|
||||
fusion::single_view<members const &> sv_ref_c_ctx( that);
|
||||
fusion::single_view<members const *> sv_ptr_c_ctx(& that);
|
||||
fusion::single_view<members_ptr const &> sv_spt_ctx(spt_that);
|
||||
fusion::single_view<const_members_ptr const &> sv_spt_c_ctx(spt_that_c);
|
||||
typedef fusion::single_view<members > sv_obj;
|
||||
typedef fusion::single_view<members &> sv_ref;
|
||||
typedef fusion::single_view<members *> sv_ptr;
|
||||
typedef fusion::single_view<members const > sv_obj_c;
|
||||
typedef fusion::single_view<members const &> sv_ref_c;
|
||||
typedef fusion::single_view<members const *> sv_ptr_c;
|
||||
typedef fusion::single_view<members_ptr const &> sv_spt;
|
||||
typedef fusion::single_view<const_members_ptr const &> sv_spt_c;
|
||||
|
||||
sv_obj sv_obj_ctx( that);
|
||||
sv_ref sv_ref_ctx( that);
|
||||
sv_ptr sv_ptr_ctx(& that);
|
||||
sv_obj_c sv_obj_c_ctx( that);
|
||||
sv_ref_c sv_ref_c_ctx( that);
|
||||
sv_ptr_c sv_ptr_c_ctx(& that);
|
||||
sv_spt sv_spt_ctx(spt_that);
|
||||
sv_spt_c sv_spt_c_ctx(spt_that_c);
|
||||
template <typename F, typename S>
|
||||
struct sv_helper
|
||||
{
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_obj , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ref , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ptr , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_obj_c, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ref_c, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ptr_c, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_spt , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_spt_c, S>::type>));
|
||||
};
|
||||
// FIXME:
|
||||
//template struct sv_helper<int (members::*)() , sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)() , sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)() , sfinae_friendly::v3>;
|
||||
//template struct sv_helper<int (members::*)() const, sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)() const, sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)() const, sfinae_friendly::v3>;
|
||||
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v3>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v3>;
|
||||
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v3>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v3>;
|
||||
|
||||
derived derived_that;
|
||||
|
||||
derived_ptr spt_derived_that(new derived);
|
||||
const_derived_ptr spt_derived_that_c(new derived);
|
||||
|
||||
fusion::single_view<derived > sv_obj_d_ctx( derived_that);
|
||||
fusion::single_view<derived &> sv_ref_d_ctx( derived_that);
|
||||
fusion::single_view<derived *> sv_ptr_d_ctx(& derived_that);
|
||||
fusion::single_view<derived const > sv_obj_c_d_ctx( derived_that);
|
||||
fusion::single_view<derived const &> sv_ref_c_d_ctx( derived_that);
|
||||
fusion::single_view<derived const *> sv_ptr_c_d_ctx(& derived_that);
|
||||
fusion::single_view<derived_ptr const &> sv_spt_d_ctx(spt_derived_that);
|
||||
fusion::single_view<const_derived_ptr const &> sv_spt_c_d_ctx(spt_derived_that_c);
|
||||
typedef fusion::single_view<derived > sv_obj_d;
|
||||
typedef fusion::single_view<derived &> sv_ref_d;
|
||||
typedef fusion::single_view<derived *> sv_ptr_d;
|
||||
typedef fusion::single_view<derived const > sv_obj_c_d;
|
||||
typedef fusion::single_view<derived const &> sv_ref_c_d;
|
||||
typedef fusion::single_view<derived const *> sv_ptr_c_d;
|
||||
typedef fusion::single_view<derived_ptr const &> sv_spt_d;
|
||||
typedef fusion::single_view<const_derived_ptr const &> sv_spt_c_d;
|
||||
|
||||
sv_obj_d sv_obj_d_ctx( derived_that);
|
||||
sv_ref_d sv_ref_d_ctx( derived_that);
|
||||
sv_ptr_d sv_ptr_d_ctx(& derived_that);
|
||||
sv_obj_c_d sv_obj_c_d_ctx( derived_that);
|
||||
sv_ref_c_d sv_ref_c_d_ctx( derived_that);
|
||||
sv_ptr_c_d sv_ptr_c_d_ctx(& derived_that);
|
||||
sv_spt_d sv_spt_d_ctx(spt_derived_that);
|
||||
sv_spt_c_d sv_spt_c_d_ctx(spt_derived_that_c);
|
||||
template <typename F, typename S>
|
||||
struct sv_d_helper
|
||||
{
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_obj_d , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ref_d , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ptr_d , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_obj_c_d, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ref_c_d, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_ptr_c_d, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_spt_d , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke<F, typename fusion::result_of::join<sv_spt_c_d, S>::type>));
|
||||
};
|
||||
// FIXME:
|
||||
//template struct sv_d_helper<int (members::*)() , sfinae_friendly::v1>;
|
||||
//template struct sv_d_helper<int (members::*)() , sfinae_friendly::v2>;
|
||||
//template struct sv_d_helper<int (members::*)() , sfinae_friendly::v3>;
|
||||
//template struct sv_d_helper<int (members::*)() const, sfinae_friendly::v1>;
|
||||
//template struct sv_d_helper<int (members::*)() const, sfinae_friendly::v2>;
|
||||
//template struct sv_d_helper<int (members::*)() const, sfinae_friendly::v3>;
|
||||
|
||||
//template struct sv_d_helper<int (members::*)(int) , sfinae_friendly::v0>;
|
||||
//template struct sv_d_helper<int (members::*)(int) , sfinae_friendly::v1>;
|
||||
//template struct sv_d_helper<int (members::*)(int) , sfinae_friendly::v2>;
|
||||
//template struct sv_d_helper<int (members::*)(int) , sfinae_friendly::v3>;
|
||||
//template struct sv_d_helper<int (members::*)(int) const, sfinae_friendly::v0>;
|
||||
//template struct sv_d_helper<int (members::*)(int) const, sfinae_friendly::v1>;
|
||||
//template struct sv_d_helper<int (members::*)(int) const, sfinae_friendly::v2>;
|
||||
//template struct sv_d_helper<int (members::*)(int) const, sfinae_friendly::v3>;
|
||||
|
||||
//template struct sv_d_helper<int (members::*)(int, object) , sfinae_friendly::v0>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) , sfinae_friendly::v1>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) , sfinae_friendly::v2>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) , sfinae_friendly::v3>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) const, sfinae_friendly::v0>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) const, sfinae_friendly::v1>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) const, sfinae_friendly::v2>;
|
||||
//template struct sv_d_helper<int (members::*)(int, object) const, sfinae_friendly::v3>;
|
||||
|
||||
template <class Sequence>
|
||||
void test_sequence_n(Sequence & seq, mpl::int_<0>)
|
||||
@ -317,7 +448,6 @@ void test_sequence_n(Sequence & seq, mpl::int_<1>)
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ref_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_ptr_c_d_ctx,seq)));
|
||||
BOOST_TEST(that.unary_c(element1) == fusion::invoke(& members::unary_c, fusion::join(sv_spt_c_d_ctx,seq)));
|
||||
|
||||
}
|
||||
|
||||
template <class Sequence>
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/join.hpp>
|
||||
|
||||
#include "../compile_time/sfinae_friendly.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
@ -82,6 +84,9 @@ struct fobj
|
||||
int operator()(int i, object const &, object_nc &);
|
||||
int operator()(int i, object const &, object_nc &) const;
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj, sfinae_friendly::v3>));
|
||||
|
||||
struct nullary_fobj
|
||||
{
|
||||
@ -90,6 +95,9 @@ struct nullary_fobj
|
||||
int operator()() { return 0; }
|
||||
int operator()() const { return 1; }
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<nullary_fobj, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<nullary_fobj, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<nullary_fobj, sfinae_friendly::v3>));
|
||||
|
||||
struct fobj_nc
|
||||
: boost::noncopyable
|
||||
@ -107,6 +115,10 @@ struct fobj_nc
|
||||
int operator()(int i) { return 14 + i; }
|
||||
int operator()(int i) const { return 15 + i; }
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj_nc, sfinae_friendly::v0>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj_nc, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj_nc, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<fobj_nc, sfinae_friendly::v3>));
|
||||
|
||||
struct nullary_fobj_nc
|
||||
: boost::noncopyable
|
||||
@ -116,6 +128,9 @@ struct nullary_fobj_nc
|
||||
int operator()() { return 12; }
|
||||
int operator()() const { return 13; }
|
||||
};
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<nullary_fobj_nc, sfinae_friendly::v1>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<nullary_fobj_nc, sfinae_friendly::v2>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_function_object<nullary_fobj_nc, sfinae_friendly::v3>));
|
||||
|
||||
|
||||
typedef int element1_type;
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <boost/fusion/iterator/advance.hpp>
|
||||
#include <boost/fusion/algorithm/transformation/join.hpp>
|
||||
|
||||
#include "../compile_time/sfinae_friendly.hpp"
|
||||
|
||||
namespace mpl = boost::mpl;
|
||||
namespace fusion = boost::fusion;
|
||||
|
||||
@ -78,14 +80,60 @@ members that;
|
||||
members_ptr spt_that(new members);
|
||||
const_members_ptr spt_that_c(new members);
|
||||
|
||||
fusion::single_view<members > sv_obj_ctx( that);
|
||||
fusion::single_view<members &> sv_ref_ctx( that);
|
||||
fusion::single_view<members *> sv_ptr_ctx(& that);
|
||||
fusion::single_view<members const > sv_obj_c_ctx( that);
|
||||
fusion::single_view<members const &> sv_ref_c_ctx( that);
|
||||
fusion::single_view<members const *> sv_ptr_c_ctx(& that);
|
||||
fusion::single_view<members_ptr const &> sv_spt_ctx(spt_that);
|
||||
fusion::single_view<const_members_ptr const &> sv_spt_c_ctx(spt_that_c);
|
||||
typedef fusion::single_view<members > sv_obj;
|
||||
typedef fusion::single_view<members &> sv_ref;
|
||||
typedef fusion::single_view<members *> sv_ptr;
|
||||
typedef fusion::single_view<members const > sv_obj_c;
|
||||
typedef fusion::single_view<members const &> sv_ref_c;
|
||||
typedef fusion::single_view<members const *> sv_ptr_c;
|
||||
typedef fusion::single_view<members_ptr const &> sv_spt;
|
||||
typedef fusion::single_view<const_members_ptr const &> sv_spt_c;
|
||||
|
||||
sv_obj sv_obj_ctx( that);
|
||||
sv_ref sv_ref_ctx( that);
|
||||
sv_ptr sv_ptr_ctx(& that);
|
||||
sv_obj_c sv_obj_c_ctx( that);
|
||||
sv_ref_c sv_ref_c_ctx( that);
|
||||
sv_ptr_c sv_ptr_c_ctx(& that);
|
||||
sv_spt sv_spt_ctx(spt_that);
|
||||
sv_spt_c sv_spt_c_ctx(spt_that_c);
|
||||
template <typename F, typename S>
|
||||
struct sv_helper
|
||||
{
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_obj , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_ref , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_ptr , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_obj_c, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_ref_c, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_ptr_c, S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_spt , S>::type>));
|
||||
SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<F, typename fusion::result_of::join<sv_spt_c, S>::type>));
|
||||
};
|
||||
// FIXME:
|
||||
//template struct sv_helper<int (members::*)() , sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)() , sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)() , sfinae_friendly::v3>;
|
||||
//template struct sv_helper<int (members::*)() const, sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)() const, sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)() const, sfinae_friendly::v3>;
|
||||
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int) , sfinae_friendly::v3>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int) const, sfinae_friendly::v3>;
|
||||
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int, object) , sfinae_friendly::v3>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v0>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v1>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v2>;
|
||||
//template struct sv_helper<int (members::*)(int, object) const, sfinae_friendly::v3>;
|
||||
|
||||
struct fobj
|
||||
{
|
||||
@ -103,6 +151,11 @@ struct fobj
|
||||
int operator()(int & i, object &, object_nc &) { return i = 10; }
|
||||
int operator()(int & i, object &, object_nc &) const { return i = 11; }
|
||||
};
|
||||
// FIXME:
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj, sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj, sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj, sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj, sfinae_friendly::v3>));
|
||||
|
||||
struct fobj_nc
|
||||
: boost::noncopyable
|
||||
@ -113,11 +166,35 @@ struct fobj_nc
|
||||
int operator()(int & i) { return i = 14; }
|
||||
int operator()(int & i) const { return i = 15; }
|
||||
};
|
||||
// FIXME:
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj_nc, sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj_nc, sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj_nc, sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<fobj_nc, sfinae_friendly::v3>));
|
||||
|
||||
int nullary() { return element1 = 16; }
|
||||
int unary(int & i) { return i = 17; }
|
||||
int binary1(int & i, object &) { return i = 18; }
|
||||
int binary2(int & i, object const &) { return i = 19; }
|
||||
//FIXME
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(), sfinae_friendly::v3>));
|
||||
//
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int), sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int), sfinae_friendly::v3>));
|
||||
//
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object &), sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object &), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object &), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object &), sfinae_friendly::v3>));
|
||||
//
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object const &), sfinae_friendly::v0>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object const &), sfinae_friendly::v1>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object const &), sfinae_friendly::v2>));
|
||||
//SFINAE_FRIENDLY_ASSERT((fusion::result_of::invoke_procedure<int(*)(int, object const &), sfinae_friendly::v3>));
|
||||
|
||||
typedef int (* func_ptr)(int &);
|
||||
typedef int (* const c_func_ptr)(int &);
|
||||
|
Reference in New Issue
Block a user