Refactoring

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@318 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2011-05-11 13:47:36 +00:00
parent f4127636d5
commit b9f50e0c4f
2 changed files with 29 additions and 53 deletions

View file

@ -20,12 +20,11 @@
#include <boost/function_types/function_type.hpp> #include <boost/function_types/function_type.hpp>
#include <boost/function_types/result_type.hpp> #include <boost/function_types/result_type.hpp>
#include <boost/type_traits/is_base_of.hpp> #include <boost/type_traits/is_base_of.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/single_view.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/equal_to.hpp> #include <boost/mpl/equal_to.hpp>
#include <boost/mpl/size_t.hpp> #include <boost/mpl/size_t.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/erase.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/back_inserter.hpp>
#define BOOST_TYPEOF_SILENT #define BOOST_TYPEOF_SILENT
#include <boost/typeof/typeof.hpp> #include <boost/typeof/typeof.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
@ -63,27 +62,20 @@ namespace detail
} }
template< typename M > template< typename M >
struct signature struct signature :
{ boost::function_types::function_type<
typedef BOOST_DEDUCED_TYPENAME boost::mpl::joint_view<
boost::function_types::result_type< M >::type result; boost::mpl::single_view<
typedef BOOST_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
boost::function_types::parameter_types< M >::type parameters; boost::function_types::result_type< M >::type
typedef BOOST_DEDUCED_TYPENAME >,
boost::function_types::function_type< BOOST_DEDUCED_TYPENAME boost::mpl::pop_front<
BOOST_DEDUCED_TYPENAME boost::mpl::push_front< BOOST_DEDUCED_TYPENAME
BOOST_DEDUCED_TYPENAME boost::mpl::pop_front< boost::function_types::parameter_types< M >
BOOST_DEDUCED_TYPENAME boost::mpl::copy<
parameters,
boost::mpl::back_inserter<
boost::mpl::vector<>
>
>::type
>::type,
result
>::type >::type
>::type type; >
}; >
{};
template< typename E > template< typename E >
void set_parent( E& e, const std::string& prefix, void set_parent( E& e, const std::string& prefix,

View file

@ -16,38 +16,22 @@
namespace namespace
{ {
void f1(); struct s
int f2( float );
BOOST_MPL_ASSERT(( boost::is_same< mock::function< void() >,
mock::function< BOOST_TYPEOF( f1 ) > > ));
BOOST_MPL_ASSERT(( boost::is_same< mock::function< int( float ) >,
mock::function< BOOST_TYPEOF( f2 ) > > ));
struct example
{ {
void method1(); void m1();
float method2( int ); float m2( int );
}; };
BOOST_STATIC_ASSERT( BOOST_MPL_ASSERT((
(boost::is_same< boost::is_same<
mock::function< void() >, void(),
mock::function< mock::detail::signature< BOOST_TYPEOF( &s::m1 ) >::type
mock::detail::signature< > ));
BOOST_TYPEOF( &example::method1 ) BOOST_MPL_ASSERT((
>::type boost::is_same<
> float( int ),
>::value) ); mock::detail::signature< BOOST_TYPEOF( &s::m2 ) >::type
BOOST_STATIC_ASSERT( > ));
(boost::is_same<
mock::function< float( int ) >,
mock::function<
mock::detail::signature<
BOOST_TYPEOF( &example::method2 )
>::type
>
>::value) );
} }
BOOST_AUTO_TEST_CASE( ptr_uniformizes_reference_and_pointer ) BOOST_AUTO_TEST_CASE( ptr_uniformizes_reference_and_pointer )