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

View file

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