Define protect(f)::result_type only when F::result_type is defined

This commit is contained in:
Peter Dimov
2020-06-30 21:58:58 +03:00
parent 1aac698358
commit 9ce9a7ce99
2 changed files with 35 additions and 3 deletions
+20
View File
@@ -18,9 +18,29 @@ struct X
struct result_type {};
};
struct Y
{
};
template<class T, class U> struct inherit: T, U
{
};
template<class F> void test2( F )
{
// test that F doesn't have ::result_type
BOOST_TEST_TRAIT_TRUE((boost::core::is_same<typename inherit<F, X>::result_type, typename X::result_type>));
}
int main()
{
test<X>( 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();
}