diff --git a/include/turtle/detail/function.hpp b/include/turtle/detail/function.hpp index fed3802..e231a95 100644 --- a/include/turtle/detail/function.hpp +++ b/include/turtle/detail/function.hpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/include/turtle/detail/is_functor.hpp b/include/turtle/detail/is_functor.hpp index ca804b7..0b8f53a 100644 --- a/include/turtle/detail/is_functor.hpp +++ b/include/turtle/detail/is_functor.hpp @@ -17,15 +17,13 @@ namespace mock { namespace detail { - template< typename F, typename P, class = void > - struct is_callable : std::false_type + /// Trait to return true if F is a functor that can be called with a single argument Arg + template< typename F, typename Arg, class = void > + struct is_functor : std::false_type {}; - template< typename F, typename P > - struct is_callable< F, P, boost::void_t()( std::declval

() ) )> >: std::true_type + template< typename F, typename Arg > + struct is_functor< F, Arg, boost::void_t()( std::declval() ) )> >: std::true_type {}; - - template< typename T, typename P > - using is_functor = is_callable< T, P >; } } // mock diff --git a/include/turtle/log.hpp b/include/turtle/log.hpp index b7728d0..06a8928 100644 --- a/include/turtle/log.hpp +++ b/include/turtle/log.hpp @@ -13,7 +13,6 @@ #include "stream.hpp" #include "format.hpp" #include -#include #include #include #include @@ -51,6 +50,15 @@ namespace detail s << (it == begin ? "" : ",") << mock::format( *it ); s << ')'; } + template + struct is_callable_impl: std::false_type + {}; + template + struct is_callable_impl: std::true_type + {}; + template + struct is_callable: is_callable_impl< std::remove_cv_t > + {}; } #ifdef MOCK_AUTO_PTR @@ -182,19 +190,13 @@ namespace detail } template< typename T > - std::enable_if_t< - boost::function_types::is_callable_builtin< T >::value, - stream& - > + std::enable_if_t< detail::is_callable< T >::value, stream& > operator<<( stream& s, T* ) { return s << '?'; } template< typename T > - std::enable_if_t< - !boost::function_types::is_callable_builtin< T >::value, - stream& - > + std::enable_if_t< !detail::is_callable< T >::value, stream& > operator<<( stream& s, T* t ) { *s.s_ << t; diff --git a/test/detail/test_is_functor.cpp b/test/detail/test_is_functor.cpp index e384f83..6d48a19 100644 --- a/test/detail/test_is_functor.cpp +++ b/test/detail/test_is_functor.cpp @@ -28,12 +28,12 @@ namespace template< typename T > void is_functor( T ) { - static_assert( mock::detail::is_functor< T, int >::value, "Should be functor"); + static_assert( mock::detail::is_functor< T, int >::value, "Should be a functor taking an int"); } template< typename T > void is_not_functor( T ) { - static_assert( !mock::detail::is_functor< T, int >::value, "Should not be a functor" ); + static_assert( !mock::detail::is_functor< T, int >::value, "Should not be a functor taking an int" ); } void f0() {}