diff --git a/include/boost/bind/protect.hpp b/include/boost/bind/protect.hpp index d6a480d..e251129 100644 --- a/include/boost/bind/protect.hpp +++ b/include/boost/bind/protect.hpp @@ -24,7 +24,21 @@ namespace _bi #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DECLTYPE) -template class protected_bind_t +template struct protect_make_void +{ + typedef void type; +}; + +template struct protect_result_type +{ +}; + +template struct protect_result_type< F, typename protect_make_void::type > +{ + typedef typename F::result_type result_type; +}; + +template class protected_bind_t: public protect_result_type { private: @@ -32,8 +46,6 @@ private: public: - typedef typename F::result_type result_type; - explicit protected_bind_t( F f ): f_( f ) { } diff --git a/test/protect_test2.cpp b/test/protect_test2.cpp index 66bec47..0c29500 100644 --- a/test/protect_test2.cpp +++ b/test/protect_test2.cpp @@ -18,9 +18,29 @@ struct X struct result_type {}; }; +struct Y +{ +}; + +template struct inherit: T, U +{ +}; + +template void test2( F ) +{ + // test that F doesn't have ::result_type + BOOST_TEST_TRAIT_TRUE((boost::core::is_same::result_type, typename X::result_type>)); +} + int main() { test( boost::protect( X() ) ); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_DECLTYPE) + + test2( boost::protect( Y() ) ); + +#endif + return boost::report_errors(); }