From 50c8cde351cf3dea78b84589565e4658f84ee112 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Wed, 15 Jun 2005 10:43:23 +0000 Subject: [PATCH] VC 7.1 has_xxx/SFINAE fix (thanks to Daniel Wallin!) [SVN r29583] --- include/boost/mpl/has_xxx.hpp | 37 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/include/boost/mpl/has_xxx.hpp b/include/boost/mpl/has_xxx.hpp index 8cc4e56..d0cb9a3 100644 --- a/include/boost/mpl/has_xxx.hpp +++ b/include/boost/mpl/has_xxx.hpp @@ -148,25 +148,36 @@ template<> struct trait \ // MSVC 7.1+ +// agurt, 15/jun/05: replace overload-based SFINAE implementation with SFINAE +// applied to partial specialization to fix some apparently random failures +// (thanks to Daniel Wallin for researching this!) + +namespace boost { namespace mpl { namespace aux { +template< typename T > struct msvc71_sfinae_helper { typedef void type; }; +}}} + # define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_) \ -template< typename T > struct BOOST_PP_CAT(trait,_wrapper_); \ -template< typename T > \ -boost::mpl::aux::yes_tag BOOST_PP_CAT(trait,_helper_)( \ - BOOST_PP_CAT(trait,_wrapper_) const volatile* \ - , BOOST_PP_CAT(trait,_wrapper_)* = 0 \ - ); \ +template< typename T, typename U = void > \ +struct BOOST_PP_CAT(trait,_impl_) \ +{ \ + BOOST_STATIC_CONSTANT(bool, value = false); \ + typedef boost::mpl::bool_ type; \ +}; \ \ -boost::mpl::aux::no_tag BOOST_PP_CAT(trait,_helper_)(...); \ +template< typename T > \ +struct BOOST_PP_CAT(trait,_impl_)< \ + T \ + , typename boost::mpl::aux::msvc71_sfinae_helper< typename T::name >::type \ + > \ +{ \ + BOOST_STATIC_CONSTANT(bool, value = true); \ + typedef boost::mpl::bool_ type; \ +}; \ \ template< typename T, typename fallback_ = boost::mpl::bool_ > \ struct trait \ + : BOOST_PP_CAT(trait,_impl_) \ { \ - typedef BOOST_PP_CAT(trait,_wrapper_) t_; \ - BOOST_STATIC_CONSTANT(bool, value = \ - sizeof((BOOST_PP_CAT(trait,_helper_))(static_cast(0))) \ - == sizeof(boost::mpl::aux::yes_tag) \ - ); \ - typedef boost::mpl::bool_ type; \ }; \ /**/