Added support for C++11 lambdas as constraints

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@620 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-04-11 16:24:26 +00:00
parent c5861a744d
commit 4afe1d32d4
6 changed files with 77 additions and 10 deletions

View file

@ -22,19 +22,29 @@
namespace
{
struct declared_but_not_defined;
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< declared_but_not_defined > ));
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< declared_but_not_defined, int > ));
template< typename T >
void is_functor( T )
{
BOOST_MPL_ASSERT(( mock::detail::is_functor< T > ));
BOOST_MPL_ASSERT(( mock::detail::is_functor< T, int > ));
}
template< typename T >
void is_not_functor( T )
{
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< T, int > ));
}
void f0 () {}
void f0() {}
bool f1( int ) { return false; }
bool f2( std::string, int ) { return false; }
}
BOOST_AUTO_TEST_CASE( data_is_not_functor )
{
is_not_functor( 42 );
}
BOOST_AUTO_TEST_CASE( function_is_functor )
{
is_functor( f0 );
@ -63,12 +73,11 @@ BOOST_AUTO_TEST_CASE( std_bind_first_is_functor )
namespace
{
struct unary_functor0 : public std::unary_function< void, void >
{
};
{};
struct unary_functor1 : public std::unary_function< int, void >
{
};
{};
}
BOOST_AUTO_TEST_CASE( std_unary_functor_is_functor )
{
is_functor( unary_functor0() );
@ -105,6 +114,7 @@ namespace
typedef void result_type;
};
}
BOOST_AUTO_TEST_CASE( class_with_result_type_is_functor )
{
is_functor( result_type_functor() );
@ -121,7 +131,20 @@ namespace
};
};
}
BOOST_AUTO_TEST_CASE( class_with_sig_is_functor )
{
is_functor( sig_functor() );
}
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_LAMBDAS)
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )
{
is_not_functor( []() {} );
is_functor( []( int ) {} );
is_not_functor( []( const std::string&, int ) {} );
is_not_functor( []( int, const std::string& ) {} );
}
#endif