Author: vitek
Date: Wed Jul 23 11:39:45 2008
New Revision: 679158

URL: http://svn.apache.org/viewvc?rev=679158&view=rev
Log:
2008-07-23  Travis Vitek  <[EMAIL PROTECTED]>

        * include/rw/_config-eccp.h: Use built-in __is_empty() trait.
        * include/rw/_meta_prop.h: Remove sunpro-5.9 workaround for
        __rw_is_const and __rw_is_volatile in favor of one that works
        with msvc-8.0 also. Add msvc-8.0 workarounds removed in r678931.
        Apply workaround for __is_empty() on eccp-3.10.
        * include/rw/_meta_rel.h: Invert logic on __rw_is_base_of_impl
        specializations to improve readability. Ensure that cv-qualified
        types are considered equal for __is_base_of_impl. Add msvc-8.0
        workarounds removed in r678931.
        * tests/utilities/20.meta.rel.cpp (test_is_same): Add cv-qual
        testing.
        (test_is_base_of): Ditto.
        (test_is_convertible) [_MSC_VER]: Work around msvc extension
        that allows conversion from function pointer to void pointer.


Modified:
    stdcxx/branches/4.3.x/include/rw/_config-eccp.h
    stdcxx/branches/4.3.x/include/rw/_meta_prop.h
    stdcxx/branches/4.3.x/include/rw/_meta_rel.h
    stdcxx/branches/4.3.x/tests/utilities/20.meta.rel.cpp

Modified: stdcxx/branches/4.3.x/include/rw/_config-eccp.h
URL: 
http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_config-eccp.h?rev=679158&r1=679157&r2=679158&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/rw/_config-eccp.h (original)
+++ stdcxx/branches/4.3.x/include/rw/_config-eccp.h Wed Jul 23 11:39:45 2008
@@ -73,8 +73,7 @@
 #  define _RWSTD_TT_IS_CLASS(T)             __is_class(T)
 #  define _RWSTD_TT_IS_POD(T)               __is_pod(T)
 
-// __is_empty() fails to detect union types
-//#  define _RWSTD_TT_IS_EMPTY(T)             __is_empty(T)
+#  define _RWSTD_TT_IS_EMPTY(T)             __is_empty(T)
 #  define _RWSTD_TT_IS_POLYMORPHIC(T)       __is_polymorphic(T)
 
 // __is_convertible_to() fails for decay and void-void conversions

Modified: stdcxx/branches/4.3.x/include/rw/_meta_prop.h
URL: 
http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_prop.h?rev=679158&r1=679157&r2=679158&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/rw/_meta_prop.h (original)
+++ stdcxx/branches/4.3.x/include/rw/_meta_prop.h Wed Jul 23 11:39:45 2008
@@ -44,80 +44,48 @@
   template <> struct Trait<Type volatile> : __rw_true_type { };      \
   template <> struct Trait<Type const volatile> : __rw_true_type { }
 
-
-#if defined (__SUNPRO_CC) && (__SUNPRO_CC <= 0x590)
-
 template <class _TypeT>
-struct __rw_is_const_impl
+struct __rw_is_const : __rw_false_type
 {
-    struct _C_no  { };
-    struct _C_yes { _C_no __pad [2]; };
-
-    template <class _TypeU>
-    struct _C_nest { };
-
-    template <class _TypeU>
-    static _C_yes _C_test (_C_nest<const _TypeU>*);
-
-    template <class _TypeU>
-    static _C_no  _C_test (_C_nest<_TypeU>*);
-
-    enum { _C_value =
-        sizeof (_C_test ((_C_nest<_TypeT>*)0)) == sizeof (_C_yes)
-    };
 };
 
 template <class _TypeT>
-struct __rw_is_const
-  : __rw_integral_constant<bool, __rw_is_const_impl<_TypeT>::_C_value>
+struct __rw_is_const<const _TypeT> : __rw_true_type
 {
 };
 
 template <class _TypeT>
-struct __rw_is_volatile_impl
+struct __rw_is_volatile : __rw_false_type
 {
-    struct _C_no  { };
-    struct _C_yes { _C_no __pad [2]; };
-
-    template <class _TypeU>
-    struct _C_nest { };
-
-    template <class _TypeU>
-    static _C_yes _C_test (_C_nest<volatile _TypeU>*);
-
-    template <class _TypeU>
-    static _C_no  _C_test (_C_nest<_TypeU>*);
-
-    enum { _C_value =
-        sizeof (_C_test ((_C_nest<_TypeT>*)0)) == sizeof (_C_yes)
-    };
 };
 
 template <class _TypeT>
-struct __rw_is_volatile
-  : __rw_integral_constant<bool, __rw_is_volatile_impl<_TypeT>::_C_value>
+struct __rw_is_volatile<volatile _TypeT> : __rw_true_type
 {
 };
 
-#else
+#if    defined (__SUNPRO_CC) && (__SUNPRO_CC <= 0x590) \
+    || defined (_MSC_VER) && (_MSC_VER <= 1400)
+
+// additional specializations needed for these compilers
 
 template <class _TypeT>
-struct __rw_is_const : __rw_false_type
+struct __rw_is_const<const _TypeT []> : __rw_true_type
 {
 };
 
-template <class _TypeT>
-struct __rw_is_const<const _TypeT> : __rw_true_type
+template <class _TypeT, _RWSTD_SIZE_T _Size>
+struct __rw_is_const<const _TypeT [_Size]> : __rw_true_type
 {
 };
 
 template <class _TypeT>
-struct __rw_is_volatile : __rw_false_type
+struct __rw_is_volatile<volatile _TypeT []> : __rw_true_type
 {
 };
 
-template <class _TypeT>
-struct __rw_is_volatile<volatile _TypeT> : __rw_true_type
+template <class _TypeT, _RWSTD_SIZE_T _Size>
+struct __rw_is_volatile<volatile _TypeT [_Size]> : __rw_true_type
 {
 };
 
@@ -140,7 +108,7 @@
 
 #  define _RWSTD_IS_POD(T) _RW::__rw_is_pod_impl<T>::_C_value
 
-#elif defined (__EDG_VERSION__)
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
 
 template <class _TypeT>
 struct __rw_is_pod_impl
@@ -181,7 +149,14 @@
 
 
 #if defined (_RWSTD_TT_IS_EMPTY)
-#  define _RWSTD_IS_EMPTY(T) _RWSTD_TT_IS_EMPTY(T)
+
+#  if defined (__EDG_VERSION__) || defined (_MSC_VER)
+#    define _RWSTD_IS_EMPTY(T) \
+        (_RWSTD_TT_IS_EMPTY(T) && !_RW::__rw_is_union<T>::value)
+#  else
+#    define _RWSTD_IS_EMPTY(T) _RWSTD_TT_IS_EMPTY(T)
+#  endif
+
 #elif defined (_RWSTD_TT_IS_CLASS) || defined (_RWSTD_TT_IS_UNION)
 
 //
@@ -212,7 +187,7 @@
 #  define _RWSTD_IS_EMPTY(T) _RW::__rw_is_empty_impl<T>::_C_value
 
 #else
-   // we have no reliable way to reliably tell if the type is empty,
+   // we have no reliable way to tell if the type is empty,
    // so we assume that it is not.
 #  define _RWSTD_IS_EMPTY(T) 0
 #endif // !_RWSTD_TT_IS_EMPTY
@@ -328,7 +303,7 @@
 
 #if !defined (_RWSTD_TT_HAS_TRIVIAL_CTOR)
 #  define _RWSTD_HAS_TRIVIAL_CTOR(T) _RW::__rw_is_pod<T>::value
-#elif defined (__EDG_VERSION__)
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
 
 template <class _TypeT>
 struct __rw_has_trivial_ctor_impl
@@ -359,7 +334,7 @@
     (  !_RW::__rw_is_array<T>::value         \
      && (   _RW::__rw_is_reference<T>::value \
          || _RW::__rw_is_pod<T>::value))
-#elif defined (__EDG_VERSION__)
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
 #  define _RWSTD_HAS_TRIVIAL_COPY(T)      \
      (   _RW::__rw_is_reference<T>::value \
       || _RW::__rw_is_scalar<T>::value    \
@@ -393,6 +368,10 @@
 #elif defined (__GNUG__)
 #  define _RWSTD_HAS_TRIVIAL_ASSIGN(T) \
     (!_RW::__rw_is_array<T>::value && _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T))
+#elif defined (_MSC_VER)
+#  define _RWSTD_HAS_TRIVIAL_ASSIGN(T) \
+        (!_RW::__rw_is_const<T>::value \
+      && (_RW::__rw_is_scalar<T>::value || _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T)))
 #else
 #  define _RWSTD_HAS_TRIVIAL_ASSIGN(T) _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T)
 #endif // _RWSTD_TT_HAS_TRIVIAL_ASSIGN
@@ -412,7 +391,7 @@
 #  define _RWSTD_HAS_TRIVIAL_DTOR(T)         \
     (  _RW::__rw_is_reference<_TypeT>::value \
      || _RWSTD_TT_HAS_TRIVIAL_DTOR (_TypeT))
-#elif defined (__EDG_VERSION__)
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
 
 template <class _TypeT>
 struct __rw_has_trivial_dtor_impl
@@ -466,7 +445,7 @@
 
 #if !defined (_RWSTD_TT_HAS_NOTHROW_CTOR)
 #  define _RWSTD_HAS_NOTHROW_CTOR(T) _RW::__rw_has_trivial_ctor<T>::value
-#elif defined (__EDG_VERSION__)
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
 
 template <class _TypeT>
 struct __rw_has_nothrow_ctor_impl
@@ -493,7 +472,7 @@
 
 #if !defined (_RWSTD_TT_HAS_NOTHROW_COPY)
 #  define _RWSTD_HAS_NOTHROW_COPY(T) _RW::__rw_has_trivial_copy<T>::value
-#elif defined (__EDG_VERSION__)
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
 #  define _RWSTD_HAS_NOTHROW_COPY(T) \
     (_RW::__rw_has_trivial_copy<T>::value || _RWSTD_TT_HAS_NOTHROW_COPY(T))
 #elif defined (__GNUG__)
@@ -512,15 +491,23 @@
 
 
 #if !defined (_RWSTD_TT_HAS_NOTHROW_ASSIGN)
-#  define _RWSTD_HAS_NOTHROW_ASSIGN(T) _RW::__rw_has_trivial_assign<T>::value
+#  define _RWSTD_HAS_NOTHROW_ASSIGN(T) \
+    _RW::__rw_has_trivial_assign<T>::value
 #elif defined (__EDG_VERSION__)
 #  define _RWSTD_HAS_NOTHROW_ASSIGN(T) \
       (!_RW::__rw_is_const<T>::value \
     && !_RW::__rw_is_reference<T>::value \
-    && (_RW::__rw_has_trivial_assign<T>::value || 
_RWSTD_TT_HAS_NOTHROW_ASSIGN(T)))
+    && (   _RW::__rw_has_trivial_assign<T>::value \
+        || _RWSTD_TT_HAS_NOTHROW_ASSIGN(T)))
 #elif defined (__GNUG__)
 #  define _RWSTD_HAS_NOTHROW_ASSIGN(T) \
-      (!_RW::__rw_is_array<T>::value && _RWSTD_TT_HAS_NOTHROW_ASSIGN(T))
+      (  !_RW::__rw_is_array<T>::value \
+       && _RWSTD_TT_HAS_NOTHROW_ASSIGN(T))
+#elif defined (_MSC_VER)
+#  define _RWSTD_HAS_NOTHROW_ASSIGN(T) \
+      (!_RW::__rw_is_const<T>::value \
+    && (   _RW::__rw_has_trivial_assign<T>::value \
+        || _RWSTD_TT_HAS_NOTHROW_ASSIGN(T)))
 #else
 #  define _RWSTD_HAS_NOTHROW_ASSIGN(T) _RWSTD_TT_HAS_NOTHROW_ASSIGN(T)
 #endif // !_RWSTD_TT_HAS_NOTHROW_ASSIGN

Modified: stdcxx/branches/4.3.x/include/rw/_meta_rel.h
URL: 
http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_rel.h?rev=679158&r1=679157&r2=679158&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/rw/_meta_rel.h (original)
+++ stdcxx/branches/4.3.x/include/rw/_meta_rel.h Wed Jul 23 11:39:45 2008
@@ -67,8 +67,8 @@
 // is not a class type.
 //
 template <class _Base, class _Derived,
-          bool =   !__rw_is_class<_Base>::value
-                || !__rw_is_class<_Derived>::value>
+          bool =   __rw_is_class<_Base>::value
+                && __rw_is_class<_Derived>::value>
 struct __rw_is_base_of_impl
 {
     enum { _C_value = 0 };
@@ -82,7 +82,7 @@
 // by Rani Sharoni [see http://tinyurl.com/6pdv3k]
 //
 template <class _Base, class _Derived>
-struct __rw_is_base_of_impl<_Base, _Derived, false>
+struct __rw_is_base_of_impl<_Base, _Derived, true>
 {
     struct _C_no  { };
     struct _C_yes { _C_no __pad [2]; };
@@ -101,7 +101,9 @@
     };
 
     enum { _C_value = 
-        sizeof (_C_yes) == sizeof (_C_nest::_C_is (_C_nest (), 0))
+           _RW::__rw_is_same<const volatile _Base,
+                             const volatile _Derived&>::value
+        || sizeof (_C_yes) == sizeof (_C_nest::_C_is (_C_nest (), 0))
     };
 };
 
@@ -110,7 +112,7 @@
 // _Derived are the same class type.
 //
 template <class _TypeT>
-struct __rw_is_base_of_impl<_TypeT, _TypeT, false>
+struct __rw_is_base_of_impl<_TypeT, _TypeT, true>
 {
     enum { _C_value = 1 };
 };
@@ -118,6 +120,11 @@
 #  define _RWSTD_IS_BASE_OF(T,U) \
      _RW::__rw_is_base_of_impl<T,U>::_C_value
 
+#elif defined (_MSC_VER)
+#  define _RWSTD_IS_BASE_OF(T,U)     \
+    (   _RW::__rw_is_class<T>::value \
+     && _RW::__rw_is_class<U>::value \
+     && _RWSTD_TT_IS_BASE_OF(T,U))
 #else
 #  define _RWSTD_IS_BASE_OF(T,U) _RWSTD_TT_IS_BASE_OF(T,U)
 #endif // _RWSTD_TT_IS_BASE_OF

Modified: stdcxx/branches/4.3.x/tests/utilities/20.meta.rel.cpp
URL: 
http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.meta.rel.cpp?rev=679158&r1=679157&r2=679158&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/utilities/20.meta.rel.cpp (original)
+++ stdcxx/branches/4.3.x/tests/utilities/20.meta.rel.cpp Wed Jul 23 11:39:45 
2008
@@ -151,6 +151,15 @@
     TEST (std::is_same, signed long, unsigned long, false);
     TEST (std::is_same, unsigned long, signed long, false);
 
+    TEST (std::is_same, long, const long, false);
+    TEST (std::is_same, const long, long, false);
+
+    TEST (std::is_same, long, volatile long, false);
+    TEST (std::is_same, volatile long, long, false);
+
+    TEST (std::is_same, long, const volatile long, false);
+    TEST (std::is_same, const volatile long, long, false);
+
     TEST (std::is_same, enum_A, char, false);
     TEST (std::is_same, enum_A, short, false);
     TEST (std::is_same, enum_A, int, false);
@@ -225,6 +234,21 @@
     TEST (std::is_base_of, struct_A, derived_private_t<struct_A>, true);
 #endif
 
+    // cv-qualified
+    TEST (std::is_base_of, const struct_A, struct_A, true);
+    TEST (std::is_base_of, struct_A, const struct_A, true);
+    TEST (std::is_base_of, volatile struct_A, struct_A, true);
+    TEST (std::is_base_of, struct_A, volatile struct_A, true);
+    TEST (std::is_base_of, const volatile struct_A, struct_A, true);
+    TEST (std::is_base_of, struct_A, const volatile struct_A, true);
+
+    TEST (std::is_base_of, const struct_A, derived_t<struct_A>, true);
+    TEST (std::is_base_of, struct_A, const derived_t<struct_A>, true);
+    TEST (std::is_base_of, volatile struct_A, derived_t<struct_A>, true);
+    TEST (std::is_base_of, struct_A, volatile derived_t<struct_A>, true);
+    TEST (std::is_base_of, const volatile struct_A, derived_t<struct_A>, true);
+    TEST (std::is_base_of, struct_A, const volatile derived_t<struct_A>, true);
+
     // other combinations should fail
     TEST (std::is_base_of, signed char, char, false);
     TEST (std::is_base_of, char, signed char, false);
@@ -367,7 +391,14 @@
     TEST (std::is_convertible, int (), int (&)(char), false);
 
     TEST (std::is_convertible, int*, void*, true);
+
+#ifdef _MSC_VER
+    // microsoft language extension allows this conversion, and that
+    // extension is enabled by default.
+    TEST (std::is_convertible, int (*)(), void*, true);
+#else
     TEST (std::is_convertible, int (*)(), void*, false);
+#endif
 
     TEST (std::is_convertible,
           int (*)(derived_t<struct_A>*),


Reply via email to