1 // protect_test2.cpp 2 // 3 // Copyright 2020 Peter Dimov 4 // Distributed under the Boost Software License, Version 1.0. 5 // https://www.boost.org/LICENSE_1_0.txt 6 7 #include <boost/bind/protect.hpp> 8 #include <boost/core/lightweight_test_trait.hpp> 9 #include <boost/core/is_same.hpp> 10 test(F)11template<class T, class F> void test( F ) 12 { 13 BOOST_TEST_TRAIT_TRUE((boost::core::is_same<typename T::result_type, typename F::result_type>)); 14 } 15 16 struct X 17 { 18 struct result_type {}; 19 }; 20 21 struct Y 22 { 23 }; 24 25 template<class T, class U> struct inherit: T, U 26 { 27 }; 28 test2(F)29template<class F> void test2( F ) 30 { 31 // test that F doesn't have ::result_type 32 BOOST_TEST_TRAIT_TRUE((boost::core::is_same<typename inherit<F, X>::result_type, typename X::result_type>)); 33 } 34 main()35int main() 36 { 37 test<X>( boost::protect( X() ) ); 38 39 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DECLTYPE) 40 41 test2( boost::protect( Y() ) ); 42 43 #endif 44 45 return boost::report_errors(); 46 } 47