Assume existance of <functional>

This commit is contained in:
Alexander Grund 2020-07-09 18:51:40 +02:00
parent f154a1a22a
commit 9faab7749c
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
6 changed files with 16 additions and 20 deletions

View file

@ -7,14 +7,14 @@
// http://www.boost.org/LICENSE_1_0.txt)
//[ invoke_functor_problem
#include <boost/function.hpp>
#include <functional>
namespace
{
class base_class
{
public:
virtual void method( const boost::function< void( int ) >& functor ) = 0;
virtual void method( const std::function< void( int ) >& functor ) = 0;
};
void function( base_class& ); // the function will call 'method' with a functor to be applied

View file

@ -40,12 +40,6 @@
# error BOOST_FT_MAX_ARITY must be set to MOCK_MAX_ARGS + 1 or higher
#endif
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
# ifndef MOCK_NO_HDR_FUNCTIONAL
# define MOCK_HDR_FUNCTIONAL
# endif
#endif
#if !defined(BOOST_NO_CXX11_HDR_MUTEX) && !defined(BOOST_NO_0X_HDR_MUTEX)
# ifndef MOCK_NO_HDR_MUTEX
# define MOCK_HDR_MUTEX

View file

@ -12,9 +12,9 @@
#include "../config.hpp"
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <functional>
#include <type_traits>
namespace mock
@ -25,13 +25,8 @@ namespace detail
class action_base
{
private:
#ifdef MOCK_HDR_FUNCTIONAL
typedef std::function< Signature > functor_type;
typedef std::function< Result() > action_type;
#else
typedef boost::function< Signature > functor_type;
typedef boost::function< Result() > action_type;
#endif
public:
const functor_type& functor() const

View file

@ -13,15 +13,15 @@
#include <boost/test/auto_unit_test.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <functional>
#include <type_traits>
// static
namespace
{
boost::function< void() > static_f;
std::function< void() > static_f;
static_assert( std::is_same< void, boost::result_of< mock::detail::function< void() >() >::type >::value, "!");
static_assert( std::is_same< int, boost::result_of< mock::detail::function< int() >() >::type >::value, "!");
@ -34,13 +34,13 @@ namespace
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor, mock_error_fixture )
{
mock::detail::function< void() > f;
boost::function< void() > functor = f;
std::function< void() > functor = f;
}
BOOST_FIXTURE_TEST_CASE( a_function_can_be_passed_as_functor_using_boost_bind_and_boost_ref, mock_error_fixture )
{
mock::detail::function< void() > f;
boost::function< void() > functor = boost::bind( boost::ref( f ) );
std::function< void() > functor = boost::bind( boost::ref( f ) );
}
// invocations

View file

@ -18,6 +18,7 @@
#endif
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <functional>
namespace
{
@ -93,6 +94,11 @@ BOOST_AUTO_TEST_CASE( boost_function_is_functor )
is_functor( boost::function< void(int) >() );
}
BOOST_AUTO_TEST_CASE( std_function_is_functor )
{
is_functor( std::function< void(int) >() );
}
#ifdef MOCK_LAMBDAS
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )

View file

@ -14,6 +14,7 @@
#include <boost/optional.hpp>
#include <boost/ref.hpp>
#include <cmath>
#include <functional>
namespace
{
@ -153,7 +154,7 @@ namespace
BOOST_FIXTURE_TEST_CASE( mock_functor_in_namespace_is_supported, mock_error_fixture )
{
boost::function< int( float, const std::string& ) > func;
std::function< int( float, const std::string& ) > func;
MOCK_EXPECT( gf ).once().with( 3, "op" ).returns( 42 );
func = gf;
BOOST_CHECK_EQUAL( 42, func( 3, "op" ) );
@ -162,7 +163,7 @@ BOOST_FIXTURE_TEST_CASE( mock_functor_in_namespace_is_supported, mock_error_fixt
BOOST_FIXTURE_TEST_CASE( mock_functor_in_function_is_supported, mock_error_fixture )
{
boost::function< int( float, const std::string& ) > func;
std::function< int( float, const std::string& ) > func;
{
MOCK_FUNCTOR( f, int( float, const std::string& ) );
MOCK_EXPECT( f ).once().with( 3, "op" ).returns( 42 );