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