mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-22 00:32:53 +02:00
makes unfused_* work through boost::result_of only
[SVN r38197]
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user