From 86be3ece35759259f0ac095caf6576b2f44cd739 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 9 Nov 2002 01:20:44 +0000 Subject: [PATCH] Previous implementation actually failed to give correct results on many good compilers. Still wondering about the use of type_wrapper* here. Wouldn't it be better to pass T*, and strip const/volatile in has_##name##_helper ? [SVN r16168] --- include/boost/mpl/aux_/has_xxx.hpp | 42 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/include/boost/mpl/aux_/has_xxx.hpp b/include/boost/mpl/aux_/has_xxx.hpp index 56ca6f0..0e2fe9e 100644 --- a/include/boost/mpl/aux_/has_xxx.hpp +++ b/include/boost/mpl/aux_/has_xxx.hpp @@ -30,28 +30,26 @@ // the implementation below is based on a USENET newsgroup's posting by // Rani Sharoni (comp.lang.c++.moderated, 2002-03-17 07:45:09 PST) -# define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \ -template< typename T > \ -boost::mpl::aux::yes_tag \ -has_##name##_helper( \ - boost::mpl::aux::type_wrapper* \ - , BOOST_MSVC_TYPENAME T::name* \ - ); \ -\ -template< typename T > \ -boost::mpl::aux::no_tag has_##name##_helper( \ - boost::mpl::aux::type_wrapper* \ - , ... \ - ); \ -\ -template< typename T > \ -struct has_##name \ -{ \ - BOOST_STATIC_CONSTANT(bool, value = \ - sizeof(has_##name##_helper((boost::mpl::aux::type_wrapper*)0, 0)) \ - == sizeof(boost::mpl::aux::yes_tag) \ - ); \ -}; \ +# define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \ +template< typename T > \ +boost::mpl::aux::yes_tag \ +has_##name##_helper( \ + boost::mpl::aux::type_wrapper* \ + , void (*)(BOOST_MSVC_TYPENAME T::name) = 0 \ + ); \ + \ +boost::mpl::aux::no_tag has_##name##_helper( \ + ... \ + ); \ + \ +template< typename T > \ +struct has_##name \ +{ \ + BOOST_STATIC_CONSTANT(bool, value = \ + sizeof((has_##name##_helper)((boost::mpl::aux::type_wrapper*)0)) \ + == sizeof(boost::mpl::aux::yes_tag) \ + ); \ +}; \ /**/ # else