makes unfused_* work through boost::result_of only

[SVN r38197]
This commit is contained in:
Tobias Schwinger
2007-07-13 14:06:50 +00:00
parent f6184f5f29
commit 7a1017dce3
8 changed files with 43 additions and 95 deletions

View File

@ -10,11 +10,11 @@
#include <boost/fusion/functional/invocation/invoke.hpp> #include <boost/fusion/functional/invocation/invoke.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/fusion/functional/adapter/detail/has_type.hpp>
#include <memory> #include <memory>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/int.hpp> #include <boost/mpl/int.hpp>
#include <boost/fusion/sequence/container/vector.hpp> #include <boost/fusion/sequence/container/vector.hpp>
@ -337,25 +337,19 @@ void test_sequence(Sequence & seq)
void result_type_tests() void result_type_tests()
{ {
using boost::fusion::detail::has_type; using boost::is_same;
BOOST_TEST(( has_type< BOOST_TEST(( is_same<
fusion::result_of::invoke<int (*)(), fusion::vector0 > fusion::result_of::invoke<int (*)(), fusion::vector0 >::type, int
>::value )); >::value ));
BOOST_TEST(( has_type< BOOST_TEST(( is_same<
fusion::result_of::invoke<int (*)(...), fusion::vector1<int> > fusion::result_of::invoke<int (*)(...), fusion::vector1<int> >::type, int
>::value )); >::value ));
BOOST_TEST(( ! has_type< BOOST_TEST(( is_same<
fusion::result_of::invoke<int (*)(), fusion::vector1<int> > fusion::result_of::invoke<int (members::*)(), fusion::vector1<members*> >::type, int
>::value )); >::value ));
BOOST_TEST(( has_type< BOOST_TEST(( is_same<
fusion::result_of::invoke<int (members::*)(), fusion::vector1<members*> > fusion::result_of::invoke<int (members::*)(...), fusion::vector2<members*,int> >::type, int
>::value ));
BOOST_TEST(( has_type<
fusion::result_of::invoke<int (members::*)(...), fusion::vector2<members*,int> >
>::value ));
BOOST_TEST(( ! has_type<
fusion::result_of::invoke<int (members::*)(), fusion::vector2<members*,int> >
>::value )); >::value ));
} }

View File

@ -42,7 +42,7 @@ struct test_func
struct result; struct result;
template <class Self, class Seq> template <class Self, class Seq>
struct result< Self(Seq) > struct result< Self(Seq &) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -41,7 +41,7 @@ struct test_func
struct result; struct result;
template <class Self, class Seq> template <class Self, class Seq>
struct result< Self(Seq) > struct result< Self(Seq &) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -39,7 +39,7 @@ struct test_func
struct result; struct result;
template <class Self, class Seq> template <class Self, class Seq>
struct result< Self(Seq) > struct result< Self(Seq &) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >,
boost::blank, mpl::identity<long> >::type boost::blank, mpl::identity<long> >::type
{ }; { };

View File

@ -10,19 +10,14 @@
#include <boost/detail/lightweight_test.hpp> #include <boost/detail/lightweight_test.hpp>
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/fusion/functional/adapter/detail/has_type.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/blank.hpp> #include <boost/blank.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp> #include <boost/fusion/algorithm/iteration/fold.hpp>
namespace fusion = boost::fusion; namespace fusion = boost::fusion;
@ -31,7 +26,7 @@ namespace mpl = boost::mpl;
using boost::noncopyable; using boost::noncopyable;
typedef mpl::true_ no_nullary_call; typedef mpl::true_ no_nullary_call;
template <class Base = boost::blank, class RemoveNullary = mpl::false_> template <class Base = boost::blank>
struct test_func struct test_func
: Base : Base
{ {
@ -39,9 +34,8 @@ struct test_func
struct result; struct result;
template <class Self, class Seq> template <class Self, class Seq>
struct result< Self(Seq) > struct result< Self (Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::identity<long>
boost::blank, mpl::identity<long> >::type
{ }; { };
template <typename Seq> template <typename Seq>
@ -62,8 +56,6 @@ struct test_func
struct fold_op struct fold_op
{ {
typedef long result_type;
template <typename T> template <typename T>
long operator()(T const & elem, long value) const long operator()(T const & elem, long value) const
{ {
@ -76,22 +68,23 @@ struct test_func
elem += sizeof(T); elem += sizeof(T);
return value; return value;
} }
template <typename Sig>
struct result;
template <class Self, typename T0, typename T1> struct result< Self(T0,T1) >
: mpl::identity<long>
{ };
}; };
}; };
void result_type_tests() void result_type_tests()
{ {
using boost::is_same; using boost::is_same;
using boost::fusion::detail::has_type;
typedef fusion::unfused_generic< test_func<noncopyable, no_nullary_call> > test_func_1; typedef fusion::unfused_generic< test_func<> > t;
typedef fusion::unfused_generic< test_func<noncopyable> > test_func_0; BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
BOOST_TEST(( has_type< test_func_0::result<test_func_0()> >::value ));
BOOST_TEST(( has_type< test_func_1::result<test_func_1(int)> >::value ));
BOOST_TEST(( ! has_type< test_func_1::result<test_func_1() > >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_0() >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_1(int) >::type, long >::value ));
} }
int main() int main()

View File

@ -12,9 +12,6 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/blank.hpp> #include <boost/blank.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
@ -26,9 +23,8 @@ namespace fusion = boost::fusion;
namespace mpl = boost::mpl; namespace mpl = boost::mpl;
using boost::noncopyable; using boost::noncopyable;
typedef mpl::true_ no_nullary_call;
template <class Base = boost::blank, class RemoveNullary = mpl::false_> template <class Base = boost::blank>
struct test_func struct test_func
: Base : Base
{ {
@ -37,8 +33,7 @@ struct test_func
template <class Self, class Seq> template <class Self, class Seq>
struct result< Self(Seq) > struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::identity<long>
boost::blank, mpl::identity<long> >::type
{ }; { };
template <typename Seq> template <typename Seq>
@ -73,16 +68,10 @@ struct test_func
void result_type_tests() void result_type_tests()
{ {
using boost::is_same; using boost::is_same;
using boost::fusion::detail::has_type;
typedef fusion::unfused_lvalue_args< test_func<noncopyable, no_nullary_call> > test_func_1; typedef fusion::unfused_lvalue_args< test_func<> > t;
typedef fusion::unfused_lvalue_args< test_func<noncopyable> > test_func_0; BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
BOOST_TEST(( has_type< test_func_0::result<test_func_0()> >::value ));
BOOST_TEST(( has_type< test_func_1::result<test_func_1(int)> >::value ));
BOOST_TEST(( ! has_type< test_func_1::result<test_func_1()> >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_0() >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_1(int) >::type, long >::value ));
} }
int main() int main()

View File

@ -12,14 +12,10 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/blank.hpp> #include <boost/blank.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp> #include <boost/fusion/algorithm/iteration/fold.hpp>
namespace fusion = boost::fusion; namespace fusion = boost::fusion;
@ -28,7 +24,7 @@ namespace mpl = boost::mpl;
using boost::noncopyable; using boost::noncopyable;
typedef mpl::true_ no_nullary_call; typedef mpl::true_ no_nullary_call;
template <class Base = boost::blank, class RemoveNullary = mpl::false_> template <class Base = boost::blank>
struct test_func struct test_func
: Base : Base
{ {
@ -37,8 +33,7 @@ struct test_func
template <class Self, class Seq> template <class Self, class Seq>
struct result< Self(Seq) > struct result< Self(Seq) >
: mpl::if_< mpl::and_< fusion::result_of::empty<Seq>, RemoveNullary >, : mpl::identity<long>
boost::blank, mpl::identity<long> >::type
{ }; { };
template <typename Seq> template <typename Seq>
@ -72,16 +67,10 @@ struct test_func
void result_type_tests() void result_type_tests()
{ {
using boost::is_same; using boost::is_same;
using boost::fusion::detail::has_type;
typedef fusion::unfused_rvalue_args< test_func<noncopyable, no_nullary_call> > test_func_1; typedef fusion::unfused_rvalue_args< test_func<> > t;
typedef fusion::unfused_rvalue_args< test_func<noncopyable> > test_func_0; BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
BOOST_TEST(( has_type< test_func_0::result<test_func_0()> >::value ));
BOOST_TEST(( has_type< test_func_1::result<test_func_1(int)> >::value ));
BOOST_TEST(( ! has_type< test_func_1::result<test_func_1()> >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_0() >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_1(int) >::type, long >::value ));
} }
int main() int main()

View File

@ -14,15 +14,10 @@
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/identity.hpp> #include <boost/mpl/identity.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/utility/result_of.hpp> #include <boost/utility/result_of.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/algorithm/iteration/fold.hpp> #include <boost/fusion/algorithm/iteration/fold.hpp>
namespace fusion = boost::fusion; namespace fusion = boost::fusion;
@ -33,12 +28,7 @@ using boost::noncopyable;
typedef fusion::vector<long &,int,char> types; typedef fusion::vector<long &,int,char> types;
typedef mpl::always< mpl::true_ > unconstrained; template <class Base = boost::blank>
typedef mpl::equal_to< fusion::result_of::size<_>,
fusion::result_of::size<types> > non_variadic;
template <class Base = boost::blank, class Validation = unconstrained>
struct test_func struct test_func
: Base : Base
{ {
@ -46,9 +36,8 @@ struct test_func
struct result; struct result;
template <class Self, class Seq> template <class Self, class Seq>
struct result<Self(Seq)> struct result< Self(Seq) >
: mpl::if_< typename mpl::apply<Validation, Seq>::type, : mpl::identity<long>
mpl::identity<long>, boost::blank >::type
{ }; { };
template <typename Seq> template <typename Seq>
@ -89,16 +78,10 @@ struct test_func
void result_type_tests() void result_type_tests()
{ {
using boost::is_same; using boost::is_same;
using boost::fusion::detail::has_type;
typedef fusion::unfused_typed< test_func<noncopyable, non_variadic>, types > test_func_3; typedef fusion::unfused_typed< test_func<>, types > t;
typedef fusion::unfused_typed< test_func<noncopyable>, types > test_func_0; BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value ));
BOOST_TEST(( has_type< test_func_0::result<test_func_0()> >::value ));
BOOST_TEST(( has_type< test_func_3::result<test_func_3(long &, int, char)> >::value ));
BOOST_TEST(( ! has_type< test_func_3::result<test_func_3()> >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_0() >::type, long >::value ));
BOOST_TEST(( is_same< boost::result_of< test_func_3(long &, int, char) >::type, long >::value ));
} }
#if defined(BOOST_MSVC) && BOOST_MSVC < 1400 #if defined(BOOST_MSVC) && BOOST_MSVC < 1400