merged from trunk

[SVN r21489]
This commit is contained in:
Dave Abrahams
2004-01-05 01:26:01 +00:00
parent 584e2797cb
commit 3f839a6698
2 changed files with 20 additions and 14 deletions

View File

@@ -33,23 +33,25 @@
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \ # define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
template< typename T > \ template< typename T > \
boost::mpl::aux::yes_tag \
trait##_helper( \
boost::mpl::aux::type_wrapper<T> const volatile* \
, boost::mpl::aux::type_wrapper<BOOST_MSVC_TYPENAME T::name>* = 0 \
); \
\
boost::mpl::aux::no_tag \
trait##_helper(...); \
\
template< typename T > \
struct trait \ struct trait \
{ \ { \
template< typename U > \
static boost::mpl::aux::yes_tag \
helper( \
boost::mpl::aux::type_wrapper<U> const volatile* \
, boost::mpl::aux::type_wrapper<BOOST_MSVC_TYPENAME U::name>* = 0 \
); \
\
static boost::mpl::aux::no_tag \
helper(...); \
\
typedef boost::mpl::aux::type_wrapper<T> t_; \ typedef boost::mpl::aux::type_wrapper<T> t_; \
BOOST_STATIC_CONSTANT(bool, value = \ \
sizeof((trait##_helper)(static_cast<t_*>(0))) \ BOOST_STATIC_CONSTANT( \
== sizeof(boost::mpl::aux::yes_tag) \ bool, value = \
); \ sizeof(trait<T>::helper(static_cast<t_*>(0))) \
== sizeof(boost::mpl::aux::yes_tag) \
); \
}; \ }; \
/**/ /**/

View File

@@ -35,6 +35,8 @@ struct b5 { typedef int xxx[10]; };
struct b6 { typedef void (*xxx)(); }; struct b6 { typedef void (*xxx)(); };
struct b7 { typedef void (xxx)(); }; struct b7 { typedef void (xxx)(); };
template <class T> struct outer;
template <class T> struct inner { typedef typename T::type type; };
int main() int main()
{ {
@@ -59,5 +61,7 @@ int main()
BOOST_STATIC_ASSERT(has_xxx<b6>::value); BOOST_STATIC_ASSERT(has_xxx<b6>::value);
BOOST_STATIC_ASSERT(has_xxx<b7>::value); BOOST_STATIC_ASSERT(has_xxx<b7>::value);
BOOST_STATIC_ASSERT(!has_xxx<outer<inner<int> > >::value);
return 0; return 0;
} }