Previous implementation actually failed to give correct results on

many good compilers.  Still wondering about the use of
type_wrapper<T>* here. Wouldn't it be better to pass T*, and strip
const/volatile in has_##name##_helper ?


[SVN r16168]
This commit is contained in:
Dave Abrahams
2002-11-09 01:20:44 +00:00
parent 8d124d88bb
commit 86be3ece35

View File

@@ -30,28 +30,26 @@
// the implementation below is based on a USENET newsgroup's posting by // 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) // Rani Sharoni (comp.lang.c++.moderated, 2002-03-17 07:45:09 PST)
# define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \ # define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \
template< typename T > \ template< typename T > \
boost::mpl::aux::yes_tag \ boost::mpl::aux::yes_tag \
has_##name##_helper( \ has_##name##_helper( \
boost::mpl::aux::type_wrapper<T>* \ boost::mpl::aux::type_wrapper<T>* \
, BOOST_MSVC_TYPENAME T::name* \ , void (*)(BOOST_MSVC_TYPENAME T::name) = 0 \
); \ ); \
\ \
template< typename T > \ boost::mpl::aux::no_tag has_##name##_helper( \
boost::mpl::aux::no_tag has_##name##_helper( \ ... \
boost::mpl::aux::type_wrapper<T>* \ ); \
, ... \ \
); \ template< typename T > \
\ struct has_##name \
template< typename T > \ { \
struct has_##name \ BOOST_STATIC_CONSTANT(bool, value = \
{ \ sizeof((has_##name##_helper)((boost::mpl::aux::type_wrapper<T>*)0)) \
BOOST_STATIC_CONSTANT(bool, value = \ == sizeof(boost::mpl::aux::yes_tag) \
sizeof(has_##name##_helper((boost::mpl::aux::type_wrapper<T>*)0, 0)) \ ); \
== sizeof(boost::mpl::aux::yes_tag) \ }; \
); \
}; \
/**/ /**/
# else # else