diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp index 6876926..6f4104e 100644 --- a/include/turtle/config.hpp +++ b/include/turtle/config.hpp @@ -46,12 +46,6 @@ # endif #endif -#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE) -# ifndef MOCK_NO_DECLTYPE -# define MOCK_DECLTYPE -# endif -#endif - #if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS) # ifndef MOCK_NO_VARIADIC_MACROS # define MOCK_VARIADIC_MACROS diff --git a/include/turtle/constraint.hpp b/include/turtle/constraint.hpp index a8c9d4f..2e0d1e0 100644 --- a/include/turtle/constraint.hpp +++ b/include/turtle/constraint.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace mock { @@ -158,7 +158,7 @@ namespace detail Expected_##n expected##n; #define MOCK_CONSTRAINT_TPL_TYPE(z, n, d) \ - typename boost::decay< const T##n >::type + std::decay_t< const T##n > #define MOCK_CONSTRAINT_CREF_PARAM(z, n, Args) \ const typename boost::unwrap_reference< Expected_##n >::type& \ diff --git a/include/turtle/constraints.hpp b/include/turtle/constraints.hpp index 4d4f9f1..3d7af0c 100644 --- a/include/turtle/constraints.hpp +++ b/include/turtle/constraints.hpp @@ -15,15 +15,13 @@ #include "detail/move_helper.hpp" #include #include -#include -#include -#include -#include +#include #if BOOST_VERSION >= 107000 #include #else #include #endif +#include namespace mock { @@ -65,7 +63,7 @@ namespace detail template< typename T1, typename T2, typename Tolerance > bool is_close( const T1& t1, const T2& t2, const Tolerance& tolerance ) { - typedef typename boost::common_type< T1, T2 >::type common_type; + typedef std::common_type_t< T1, T2 > common_type; return boost::math::fpc::close_at_tolerance< common_type >( tolerance, boost::math::fpc::FPC_STRONG )( t1, t2 ); } @@ -114,6 +112,14 @@ namespace detail namespace detail { + template + struct has_equal_to: std::false_type + {}; + + template + struct has_equal_to() == std::declval())>>: std::true_type + {}; + template< typename Expected > struct equal { @@ -122,25 +128,25 @@ namespace detail {} template< typename Actual > bool operator()( const Actual& actual, - typename boost::enable_if< - boost::has_equal_to< + std::enable_if_t< + has_equal_to< Actual, typename boost::unwrap_reference< Expected >::type - > - >::type* = 0 ) const + >::value + >* = 0 ) const { return actual == boost::unwrap_ref( expected_ ); } template< typename Actual > bool operator()( const Actual& actual, - typename boost::disable_if< - boost::has_equal_to< + std::enable_if_t< + !has_equal_to< Actual, typename boost::unwrap_reference< Expected >::type - > - >::type* = 0 ) const + >::value + >* = 0 ) const { return actual && *actual == boost::unwrap_ref( expected_ ); } @@ -178,38 +184,38 @@ namespace detail {} template< typename Actual > bool operator()( const Actual& actual, - typename boost::disable_if< - boost::is_convertible< + std::enable_if_t< + !std::is_convertible< const Actual*, typename boost::unwrap_reference< Expected >::type - > - >::type* = 0 ) const + >::value + >* = 0 ) const { *expected_ = actual; return true; } template< typename Actual > bool operator()( Actual&& actual, - typename boost::disable_if< - boost::is_convertible< + std::enable_if_t< + !std::is_convertible< const Actual*, typename boost::unwrap_reference< Expected >::type - > - >::type* = 0 ) const + >::value + >* = 0 ) const { *expected_ = std::move( actual ); return true; } template< typename Actual > bool operator()( Actual& actual, - typename boost::enable_if< - boost::is_convertible< Actual*, + std::enable_if_t< + std::is_convertible< Actual*, typename boost::unwrap_reference< Expected >::type - > - >::type* = 0 ) const + >::value + >* = 0 ) const { *expected_ = detail::addressof( actual ); return true; @@ -236,13 +242,13 @@ namespace detail } template< typename Actual > bool operator()( Actual* actual, - typename boost::enable_if< - boost::is_convertible< + std::enable_if_t< + std::is_convertible< typename boost::unwrap_reference< Expected >::type, Actual - > - >::type* = 0 ) const + >::value + >* = 0 ) const { if( ! actual ) return false; diff --git a/include/turtle/detail/action.hpp b/include/turtle/detail/action.hpp index 47360d8..8cdfe72 100644 --- a/include/turtle/detail/action.hpp +++ b/include/turtle/detail/action.hpp @@ -10,13 +10,12 @@ #define MOCK_ACTION_HPP_INCLUDED #include "../config.hpp" -#include -#include #include #include #include #include #include +#include namespace mock { @@ -108,7 +107,7 @@ namespace detail { this->set( boost::bind( - &move< typename boost::remove_reference< Value >::type >, + &move< std::remove_reference_t< Value > >, boost::ref( store( std::move( v ) ) ) ) ); } @@ -126,12 +125,7 @@ namespace detail template< typename T > struct value_imp : value { - typedef - typename boost::remove_const< - typename boost::remove_reference< - T - >::type - >::type value_type; + typedef std::remove_const_t> value_type; value_imp( value_type&& t ) : t_( std::move( t ) ) @@ -159,7 +153,7 @@ namespace detail return static_cast< value_imp< T >& >( *v_ ).t_; } template< typename T > - typename boost::remove_reference< Result >::type& store( T* t ) + std::remove_reference_t< Result >& store( T* t ) { v_.reset( new value_imp< Result >( t ) ); return static_cast< value_imp< Result >& >( *v_ ).t_; diff --git a/include/turtle/detail/is_functor.hpp b/include/turtle/detail/is_functor.hpp index 5d4de95..817213a 100644 --- a/include/turtle/detail/is_functor.hpp +++ b/include/turtle/detail/is_functor.hpp @@ -11,10 +11,11 @@ #include "../config.hpp" #include -#include #include #include #include +#include +#include namespace mock { @@ -24,33 +25,18 @@ namespace detail BOOST_MPL_HAS_XXX_TEMPLATE_DEF( sig ) BOOST_MPL_HAS_XXX_TEMPLATE_DEF( result ) -#ifdef MOCK_DECLTYPE - + template< typename F, typename P, class = void > + struct is_callable : std::false_type + {}; template< typename F, typename P > - struct is_callable - { - typedef boost::type_traits::yes_type yes_type; - typedef boost::type_traits::no_type no_type; - - template< typename T > - static yes_type check( - decltype( boost::declval< T >()( boost::declval< P >() ) )* ); - template< typename T > - static no_type check( ... ); - - typedef boost::mpl::bool_< - sizeof( check< F >( 0 ) ) == sizeof( yes_type ) > type; - }; - -#endif // MOCK_DECLTYPE + struct is_callable< F, P, boost::void_t()( std::declval

() ) )> >: std::true_type + {}; template< typename T, typename P > struct is_functor : boost::mpl::or_< boost::function_types::is_callable_builtin< T >, -#ifdef MOCK_DECLTYPE is_callable< T, P >, -#endif has_result_type< T >, has_result< T >, has_sig< T > diff --git a/include/turtle/detail/move_helper.hpp b/include/turtle/detail/move_helper.hpp index 75b173d..9d910ff 100644 --- a/include/turtle/detail/move_helper.hpp +++ b/include/turtle/detail/move_helper.hpp @@ -9,22 +9,18 @@ #ifndef MOCK_MOVE_HELPER_HPP_INCLUDED #define MOCK_MOVE_HELPER_HPP_INCLUDED -#include -#include -#include +#include namespace mock { namespace detail { template< typename T > - struct ref_arg - { - typedef typename boost::conditional< - boost::is_reference< T >::value, + using ref_arg = std::conditional< + std::is_reference< T >::value, T, - typename boost::add_rvalue_reference< T >::type >::type type; - }; + std::add_rvalue_reference_t< T > + >; } } diff --git a/include/turtle/log.hpp b/include/turtle/log.hpp index 104c9fe..b196ec0 100644 --- a/include/turtle/log.hpp +++ b/include/turtle/log.hpp @@ -12,11 +12,11 @@ #include "config.hpp" #include "stream.hpp" #include "format.hpp" -#include #include #include #include #include +#include namespace boost { @@ -181,19 +181,19 @@ namespace detail #endif template< typename T > - typename boost::enable_if< - boost::function_types::is_callable_builtin< T >, + std::enable_if_t< + boost::function_types::is_callable_builtin< T >::value, stream& - >::type + > operator<<( stream& s, T* ) { return s << '?'; } template< typename T > - typename boost::disable_if< - boost::function_types::is_callable_builtin< T >, + std::enable_if_t< + !boost::function_types::is_callable_builtin< T >::value, stream& - >::type + > operator<<( stream& s, T* t ) { *s.s_ << t; diff --git a/include/turtle/matcher.hpp b/include/turtle/matcher.hpp index 4429164..aed74ea 100644 --- a/include/turtle/matcher.hpp +++ b/include/turtle/matcher.hpp @@ -14,10 +14,9 @@ #include "constraints.hpp" #include "detail/is_functor.hpp" #include "detail/move_helper.hpp" -#include -#include #include #include +#include namespace mock { @@ -28,7 +27,7 @@ namespace mock explicit matcher( Expected expected ) : expected_( expected ) {} - bool operator()( typename boost::add_reference< const Actual >::type actual ) + bool operator()( std::add_lvalue_reference_t< const Actual > actual ) { return mock::equal( boost::unwrap_ref( expected_ ) ).c_( actual ); @@ -84,9 +83,9 @@ namespace mock template< typename Actual, typename Functor > class matcher< Actual, Functor, - typename boost::enable_if< - detail::is_functor< Functor, Actual > - >::type + std::enable_if_t< + detail::is_functor< Functor, Actual >::value + > > { public: diff --git a/include/turtle/mock.hpp b/include/turtle/mock.hpp index d5c5cff..af0cc12 100644 --- a/include/turtle/mock.hpp +++ b/include/turtle/mock.hpp @@ -28,7 +28,7 @@ struct T : mock::object #define MOCK_FUNCTION_TYPE(S, tpn) \ - tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE(S) >::type + std::remove_pointer_t< tpn BOOST_IDENTITY_TYPE(S) > #ifdef MOCK_VARIADIC_MACROS diff --git a/include/turtle/object.hpp b/include/turtle/object.hpp index d201757..9f473cd 100644 --- a/include/turtle/object.hpp +++ b/include/turtle/object.hpp @@ -14,10 +14,9 @@ #include "detail/type_name.hpp" #include "detail/object_impl.hpp" #include -#include -#include #include #include +#include namespace mock { @@ -36,9 +35,7 @@ namespace detail boost::unit_test::const_string instance, boost::optional< type_name > type, boost::unit_test::const_string name, - typename boost::disable_if< - typename boost::is_base_of< object, T > - >::type* = 0 ) + std::enable_if_t< !std::is_base_of< object, T >::value >* = 0 ) { e.configure( detail::root, &t, instance, type, name ); return e; diff --git a/test/detail/test_function.cpp b/test/detail/test_function.cpp index 270fbe2..599d89f 100644 --- a/test/detail/test_function.cpp +++ b/test/detail/test_function.cpp @@ -16,6 +16,7 @@ #include #include #include +#include // static @@ -23,14 +24,10 @@ namespace { boost::function< void() > static_f; - BOOST_MPL_ASSERT(( - boost::is_same< void, boost::result_of< mock::detail::function< void() >() >::type > )); - BOOST_MPL_ASSERT(( - boost::is_same< int, boost::result_of< mock::detail::function< int() >() >::type > )); - BOOST_MPL_ASSERT(( - boost::is_same< void, boost::result_of< mock::detail::function< void( float ) >( float ) >::type > )); - BOOST_MPL_ASSERT(( - boost::is_same< int, boost::result_of< mock::detail::function< int( float ) >( float ) >::type > )); + 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, "!"); + static_assert( std::is_same< void, boost::result_of< mock::detail::function< void( float ) >( float ) >::type >::value, "!"); + static_assert( std::is_same< int, boost::result_of< mock::detail::function< int( float ) >( float ) >::type >::value, "!"); } // functor diff --git a/test/detail/test_is_functor.cpp b/test/detail/test_is_functor.cpp index a6a0f38..88adf31 100644 --- a/test/detail/test_is_functor.cpp +++ b/test/detail/test_is_functor.cpp @@ -143,11 +143,7 @@ BOOST_AUTO_TEST_CASE( class_with_sig_is_functor ) BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor ) { is_not_functor( []() {} ); -#ifdef MOCK_DECLTYPE is_functor( []( int ) {} ); -#else - is_not_functor( []( int ) {} ); -#endif is_not_functor( []( const std::string&, int ) {} ); is_not_functor( []( int, const std::string& ) {} ); } diff --git a/test/detail/test_signature.cpp b/test/detail/test_signature.cpp index 27f4e91..c366aae 100644 --- a/test/detail/test_signature.cpp +++ b/test/detail/test_signature.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include namespace { @@ -22,8 +22,6 @@ namespace BOOST_AUTO_TEST_CASE( mock_signature_generates_signature ) { - BOOST_MPL_ASSERT(( - boost::is_same< void(), MOCK_SIGNATURE(method_1) > )); - BOOST_MPL_ASSERT(( - boost::is_same< float( int ), MOCK_SIGNATURE(method_2) > )); + static_assert( std::is_same< void(), MOCK_SIGNATURE(method_1) >::value, "!"); + static_assert( std::is_same< float( int ), MOCK_SIGNATURE(method_2) >::value, "!"); }