Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 19934 invoked from network); 8 Jul 2008 23:26:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jul 2008 23:26:12 -0000 Received: (qmail 93747 invoked by uid 500); 8 Jul 2008 23:26:12 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 93728 invoked by uid 500); 8 Jul 2008 23:26:12 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 93719 invoked by uid 99); 8 Jul 2008 23:26:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 16:26:12 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 23:25:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6BBD523889FE; Tue, 8 Jul 2008 16:25:20 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r675050 - in /stdcxx/branches/4.3.x: include/rw/ tests/utilities/ Date: Tue, 08 Jul 2008 23:25:19 -0000 To: commits@stdcxx.apache.org From: vitek@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080708232520.6BBD523889FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: vitek Date: Tue Jul 8 16:25:19 2008 New Revision: 675050 URL: http://svn.apache.org/viewvc?rev=675050&view=rev Log: 2008-07-09 Travis Vitek STDCXX-916 * include/rw/_meta_help.h: Remove doxygen tags from comments. * include/rw/_meta_prop.h: Reduce lines to 76 characters or less where necessary. [_MSC_VER]: Simplify workaround for broken __is_pod() and __is_empty(). [!_RWSTD_TT_IS_STANDARD_LAYOUT]: Change fallback for the __rw_is_standard_layout<> trait to be more reliable. [!_RWSTD_TT_IS_EMPTY]: Change fallback for __rw_is_empty<> trait to be more reliable. [!_RWSTD_TT_IS_POLYMORPHIC]: Add fallback to detect polymorphic class types when compiler support is not available. [!_RWSTD_TT_IS_ABSTRACT]: Add fallback to detect abstract class types when compiler support is not available. [!_RWSTD_TT_HAS_TRIVIAL_CTOR]: Add fallback to detect types that have a trivial constructor when compiler support is not available. [!_RWSTD_TT_HAS_TRIVIAL_COPY]: Add fallback to detect types that have a trivial copy constructor when compiler support is not available. [!_RWSTD_TT_HAS_TRIVIAL_ASSIGN]: Add fallback to detect types that have a trivial assignment operator when compiler support is not available. [!_RWSTD_TT_HAS_TRIVIAL_DTOR]: Add fallback to detect types that have a trivial destructor when compiler support is not available. [!_RWSTD_TT_HAS_NOTHROW_CTOR]: Add fallback to detect types that have a nothrow constructor when compiler support is not available. [!_RWSTD_TT_HAS_NOTHROW_COPY]: Add fallback to detect types that have a nothrow copy constructor when compiler support is not available. [!_RWSTD_TT_HAS_NOTHROW_ASSIGN]: Add fallback to detect types that have a nothrow assignment operator when compiler support is not available. [!_RWSTD_TT_HAS_VIRTUAL_DTOR]: Add fallback to detect types that have a virtual destructor when compiler support is not available. Currently tests that the type is polymorphic, which may not be entirely accurate. * include/rw/_meta_other.h [__GNUG__]: Use simpler implementation for __rw_aligned_storage<>. Reorder union members to make most strictly aligned member first. [_RWSTD_TT_MAX_ALIGNMENT]: Guard __rw_aligned_storage_impl<> specializations to prevent their use when the requested alignment is out of range. * include/rw/_meta_comp.h: Reduce lines to 76 characters or less. * include/rw/_meta_cat.h: Add __rw_is_class_or_union<> helper. [!_RWSTD_TT_IS_CLASS]: Add fallback to detect class types, using _RWSTD_TT_IS_UNION if available. [!_RWSTD_TT_IS_UNION]: Add fallback to detect union types, using _RWSTD_TT_IS_CLASS if available. [!_RWSTD_TT_IS_ENUM]: Add fallback to detect enum types when compiler support is not available. [!_RWSTD_TT_IS_FUNCTION]: Fix fallback for __rw_is_function to avoid compiler warnings on HP aCC 6.16. * include/rw/_meta_ref.h: Reduce lines to 76 characters or less. Remove use of _TYPENAME macro. * include/rw/_meta_rel.h: Fix __rw_is_convertible_impl to avoid warning on HP aCC 6.16. Reduce lines to 76 characters or less. Remove use of _TYPENAME macro. Fix __rw_is_convertible_impl<> to avoid compiler warnings on HP aCC 6.16. [_RWSTD_TT_IS_CONVERTIBLE]: Guard header inclusion. Rename template parameters to _From and _To for clarity. [_RWSTD_TT_IS_BASE_OF]: Guard header inclusion. Change fallback for __rw_is_base_of to be more reliable. Rename template parameters to _Base and _Derived for clarity. * include/rw/_config-gcc.h [__GNUG__]: Reduce lines to 76 characters or less where necessary. Work around issue with gcc aligned attribute so we can use it to define __rw_aligned_storage<>. * include/rw/_config-acc.h [__HP_aCC]: Add macros _RWSTD_TT_ALIGN_OF, _RWSTD_TT_MAX_ALIGNMENT, and _RWSTD_TT_ALIGNED_POD. * include/rw/_config-msvc.h [_MSC_VER]: Remove comments about broken __is_pod(). Reduce lines to 76 characters or less where necessary. Provide accurate definition of _RWSTD_TT_MAX_ALIGNMENT. * tests/utilities/20.meta.trans.other.cpp: Add include for stddef.h. Use std::alignment_of<> instead of __alignof() for portability. Test default alignment for various aligned storage sizes. * tests/utilities/20.meta.rel.cpp (test_is_base_of): Fix test cases that were failing due to parameter ordering. Modified: stdcxx/branches/4.3.x/include/rw/_config-acc.h stdcxx/branches/4.3.x/include/rw/_config-gcc.h stdcxx/branches/4.3.x/include/rw/_config-msvc.h stdcxx/branches/4.3.x/include/rw/_meta_cat.h stdcxx/branches/4.3.x/include/rw/_meta_comp.h stdcxx/branches/4.3.x/include/rw/_meta_help.h stdcxx/branches/4.3.x/include/rw/_meta_other.h stdcxx/branches/4.3.x/include/rw/_meta_prop.h stdcxx/branches/4.3.x/include/rw/_meta_ref.h stdcxx/branches/4.3.x/include/rw/_meta_rel.h stdcxx/branches/4.3.x/tests/utilities/20.meta.rel.cpp stdcxx/branches/4.3.x/tests/utilities/20.meta.trans.other.cpp Modified: stdcxx/branches/4.3.x/include/rw/_config-acc.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_config-acc.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_config-acc.h (original) +++ stdcxx/branches/4.3.x/include/rw/_config-acc.h Tue Jul 8 16:25:19 2008 @@ -104,3 +104,12 @@ # define _RWSTD_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) #endif // aCC >= 6 + +#if 60000 <= __HP_aCC +# define _RWSTD_TT_ALIGN_OF(T) __alignof__(T) +# define _RWSTD_TT_MAX_ALIGNMENT 128 +# define _RWSTD_TT_ALIGNED_POD(N) \ + struct { unsigned char _C_align __attribute__ ((aligned ((N)))); } +#endif // + + Modified: stdcxx/branches/4.3.x/include/rw/_config-gcc.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_config-gcc.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_config-gcc.h (original) +++ stdcxx/branches/4.3.x/include/rw/_config-gcc.h Tue Jul 8 16:25:19 2008 @@ -176,30 +176,29 @@ #endif // _RWSTD_OS_SUNOS #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) -# define _RWSTD_TT_IS_ENUM(T) __is_enum(T) -# define _RWSTD_TT_IS_UNION(T) __is_union(T) -# define _RWSTD_TT_IS_CLASS(T) __is_class(T) -//# define _RWSTD_TT_IS_FUNCTION(T) __is_function(T) -# define _RWSTD_TT_IS_POD(T) __is_pod(T) -# define _RWSTD_TT_IS_EMPTY(T) __is_empty(T) -# define _RWSTD_TT_IS_POLYMORPHIC(T) __is_polymorphic(T) -# define _RWSTD_TT_IS_ABSTRACT(T) __is_abstract(T) -# define _RWSTD_TT_IS_BASE_OF(T,U) __is_base_of(T,U) -//# define _RWSTD_TT_IS_CONVERTIBLE(T,U) __is_convertible(T,U) - -# define _RWSTD_TT_HAS_TRIVIAL_CTOR(T) __has_trivial_constructor(T) -# define _RWSTD_TT_HAS_TRIVIAL_COPY(T) __has_trivial_copy(T) -# define _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T) -# define _RWSTD_TT_HAS_TRIVIAL_DTOR(T) __has_trivial_destructor(T) - -# define _RWSTD_TT_HAS_NOTHROW_CTOR(T) __has_nothrow_constructor(T) -# define _RWSTD_TT_HAS_NOTHROW_COPY(T) __has_nothrow_copy(T) -# define _RWSTD_TT_HAS_NOTHROW_ASSIGN(T) __has_nothrow_assign(T) - -# define _RWSTD_TT_HAS_VIRTUAL_DTOR(T) __has_virtual_destructor(T) - -# define _RWSTD_TT_ALIGN_OF(T) __alignof__(T) -# define _RWSTD_TT_ALIGNED_POD(N) struct { char __fill __attribute__ ((aligned (N))); } -# define _RWSTD_TT_MAX_ALIGNMENT 16 +# define _RWSTD_TT_IS_ENUM(T) __is_enum(T) +# define _RWSTD_TT_IS_UNION(T) __is_union(T) +# define _RWSTD_TT_IS_CLASS(T) __is_class(T) +# define _RWSTD_TT_IS_POD(T) __is_pod(T) +# define _RWSTD_TT_IS_EMPTY(T) __is_empty(T) +# define _RWSTD_TT_IS_POLYMORPHIC(T) __is_polymorphic(T) +# define _RWSTD_TT_IS_ABSTRACT(T) __is_abstract(T) +# define _RWSTD_TT_IS_BASE_OF(T,U) __is_base_of(T,U) + +# define _RWSTD_TT_HAS_TRIVIAL_CTOR(T) __has_trivial_constructor(T) +# define _RWSTD_TT_HAS_TRIVIAL_COPY(T) __has_trivial_copy(T) +# define _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T) +# define _RWSTD_TT_HAS_TRIVIAL_DTOR(T) __has_trivial_destructor(T) + +# define _RWSTD_TT_HAS_NOTHROW_CTOR(T) __has_nothrow_constructor(T) +# define _RWSTD_TT_HAS_NOTHROW_COPY(T) __has_nothrow_copy(T) +# define _RWSTD_TT_HAS_NOTHROW_ASSIGN(T) __has_nothrow_assign(T) + +# define _RWSTD_TT_HAS_VIRTUAL_DTOR(T) __has_virtual_destructor(T) + +# define _RWSTD_TT_ALIGN_OF(T) __alignof__(T) +# define _RWSTD_TT_MAX_ALIGNMENT 16 +# define _RWSTD_TT_ALIGNED_POD(N) \ + struct { unsigned char _C_align __attribute__ ((aligned ((N)))); } #endif // __GNUC__ >= 4.3 Modified: stdcxx/branches/4.3.x/include/rw/_config-msvc.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_config-msvc.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_config-msvc.h (original) +++ stdcxx/branches/4.3.x/include/rw/_config-msvc.h Tue Jul 8 16:25:19 2008 @@ -103,6 +103,7 @@ # define _RWSTD_TT_IS_ABSTRACT(T) __is_abstract(T) # define _RWSTD_TT_IS_BASE_OF(T,U) __is_base_of(T,U) # define _RWSTD_TT_IS_CLASS(T) __is_class(T) +# define _RWSTD_TT_IS_POD(T) __is_pod(T) # define _RWSTD_TT_IS_CONVERTIBLE(T,U) __is_convertible_to(T,U) # define _RWSTD_TT_IS_EMPTY(T) __is_empty(T) # define _RWSTD_TT_IS_ENUM(T) __is_enum(T) @@ -110,15 +111,9 @@ # define _RWSTD_TT_IS_UNION(T) __is_union(T) # define _RWSTD_TT_ALIGN_OF(T) __alignof(T) -# define _RWSTD_TT_ALIGNED_POD(N) struct { __declspec(align(N)) char __fill; } -# define _RWSTD_TT_MAX_ALIGNMENT 16 -//# define _RWSTD_TT_MAX_ALIGNMENT 8192 - -// __is_pod only seems to work for pod-class and pod-union types according -// to the old definition of pod. it needs to exclude scalar types, as well -// as types which are both trivial and standard layout. so, we work around -// that by using our fallback. -# define _RWSTD_TT_IS_POD(T) __is_pod(T) +# define _RWSTD_TT_ALIGNED_POD(N) \ + struct {__declspec(align(Align)) unsigned char _C_align; } +# define _RWSTD_TT_MAX_ALIGNMENT 8192 #endif // _MSC_FULL_VER >= 140050215 Modified: stdcxx/branches/4.3.x/include/rw/_meta_cat.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_cat.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_cat.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_cat.h Tue Jul 8 16:25:19 2008 @@ -184,13 +184,37 @@ _RW::__rw_is_rvalue_reference::value + template -struct __rw_is_enum - : __rw_integral_constant +struct __rw_is_class_or_union { -}; + struct _C_no { }; + struct _C_yes { _C_no __pad[2]; }; -#define _RWSTD_IS_ENUM(T) _RW::__rw_is_enum::value + template + static _C_yes _C_is (int, long _TypeU::*); + + template + static _C_no _C_is (int, ...); + + enum { value = + sizeof (_C_yes) == sizeof (_C_is<_TypeT>(0, 0)) + }; +}; + +// if one of _RWSTD_TT_IS_CLASS or _RWSTD_TT_IS_UNION is defined, then +// this will all work out. if neither is defined, then we say all class +// types (including unios) are classes and none of them are unions. +#if !defined (_RWSTD_TT_IS_CLASS) && !defined (_RWSTD_TT_IS_UNION) +# define _RWSTD_TT_IS_CLASS(T) _RW::__rw_is_class_or_union::value +# define _RWSTD_TT_IS_UNION(T) 0 +#elif !defined (_RWSTD_TT_IS_CLASS) +# define _RWSTD_TT_IS_CLASS(T) \ + _RW::__rw_is_class_or_union::value && !_RWSTD_TT_IS_UNION(T) +#elif !defined (_RWSTD_TT_IS_UNION) +# define _RWSTD_TT_IS_UNION(T) \ + _RW::__rw_is_class_or_union::value && !_RWSTD_TT_IS_CLASS(T) +#endif template struct __rw_is_union @@ -210,44 +234,111 @@ #define _RWSTD_IS_CLASS(T) _RW::__rw_is_class::value + + +#ifndef _RWSTD_TT_IS_ENUM + +template ::value + || __rw_is_array<_TypeT>::value + || __rw_is_integral<_TypeT>::value + || __rw_is_floating_point<_TypeT>::value + || __rw_is_lvalue_reference<_TypeT>::value + || __rw_is_rvalue_reference<_TypeT>::value + || __rw_is_class_or_union<_TypeT>::value> +struct __rw_is_enum_impl +{ + enum { _C_value = 0 }; +}; + +// +template +struct __rw_is_enum_impl<_TypeT, false> +{ + struct _C_no { }; + struct _C_yes { _C_no __pad [2]; }; + + // supply first argument to prevent HP aCC warnings + static _C_no _C_is (int, ...); + static _C_yes _C_is (int, double); + + static _TypeT& _C_make (); + + enum { + _C_value = sizeof (_C_yes) == sizeof (_C_is (0, _C_make ())) + }; +}; + +# define _RWSTD_TT_IS_ENUM(T) _RW::__rw_is_enum_impl::_C_value +#endif // _RWSTD_TT_IS_ENUM + +template +struct __rw_is_enum + : __rw_integral_constant +{ +}; + +#define _RWSTD_IS_ENUM(T) _RW::__rw_is_enum::value + + + + +#ifndef _RWSTD_TT_IS_FUNCTION + +// +// This template prevents the partial specialization below from +// being instantiated on types for which it would fail or give +// invalid results. i.e. it avoids creating references to void or +// arrays with unknown length and for returning bad results for +// references to functions. +// template ::value || __rw_is_array<_TypeT>::value + || __rw_is_pointer<_TypeT>::value || __rw_is_lvalue_reference<_TypeT>::value - || __rw_is_rvalue_reference<_TypeT>::value> + || __rw_is_rvalue_reference<_TypeT>::value + || __rw_is_class_or_union<_TypeT>::value> struct __rw_is_function_impl { enum { _C_value = 0 }; }; +// +// This specialization determines if _TypeT is a function type. This +// is done by testing that a _TypeT is implicitly convertible to a +// pointer to _TypeT. This special case is only true for functions +// and member functions. +// template struct __rw_is_function_impl<_TypeT, false> { typedef _TypeT& _TypeT_Ref; - typedef _TypeT* _TypeT_Ptr; + typedef _TypeT* _TypeT_Ptr; struct _C_no { }; struct _C_yes { _C_no __pad [2]; }; - static _C_yes _C_is (int, _TypeT_Ptr); - static _C_no _C_is (int, ...); + static _C_yes _C_is (_TypeT_Ptr); + + template + static _C_no _C_is (_TypeU); static _TypeT_Ref _C_make (); - enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (0, _C_make ())) }; + enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (_C_make ())) }; }; +# define _RWSTD_TT_IS_FUNCTION(T) _RW::__rw_is_function_impl::_C_value +#endif //_RWSTD_TT_IS_FUNCTION + template struct __rw_is_function -#ifdef _RWSTD_TT_IS_FUNCTION : __rw_integral_constant -#else - : __rw_integral_constant::_C_value> -#endif // _RWSTD_TT_IS_FUNCTION { }; #define _RWSTD_IS_FUNCTION(T) _RW::__rw_is_function::value + template struct __rw_is_member_object_pointer : __rw_false_type { Modified: stdcxx/branches/4.3.x/include/rw/_meta_comp.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_comp.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_comp.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_comp.h Tue Jul 8 16:25:19 2008 @@ -37,8 +37,9 @@ template struct __rw_is_reference - : __rw_integral_constant::value - || __rw_is_rvalue_reference<_TypeT>::value> + : __rw_integral_constant::value + || __rw_is_rvalue_reference<_TypeT>::value> { }; @@ -46,8 +47,9 @@ template struct __rw_is_arithmetic - : __rw_integral_constant::value - || __rw_is_floating_point<_TypeT>::value> + : __rw_integral_constant::value + || __rw_is_floating_point<_TypeT>::value> { }; @@ -76,8 +78,9 @@ template struct __rw_is_member_pointer - : __rw_integral_constant::value - || __rw_is_member_object_pointer<_TypeT>::value> + : __rw_integral_constant::value + || __rw_is_member_object_pointer<_TypeT>::value> { }; Modified: stdcxx/branches/4.3.x/include/rw/_meta_help.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_help.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_help.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_help.h Tue Jul 8 16:25:19 2008 @@ -34,27 +34,16 @@ _RWSTD_NAMESPACE (__rw) { -/** - * @internal - * A compile-time integral constant wrapper. This class template - * encapsulates an integer constant value for metaprogramming. - */ +// +// A compile-time integral constant wrapper. This class template +// encapsulates an integer constant value for metaprogramming. +// template struct __rw_integral_constant { - /** - * Describes the type of this integral_constant. - */ typedef __rw_integral_constant<_TypeT,_Value> type; - - /** - * Describes the type of the value defined by this integral_constant. - */ typedef _TypeT value_type; - /** - * The actual integral constant value. - */ static const _TypeT value = _Value; }; @@ -65,16 +54,14 @@ #endif // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION -/** - * @internal - * Synonym for __rw_integral_constant type. - */ +// +// Synonym for __rw_integral_constant type. +// typedef __rw_integral_constant __rw_true_type; -/** - * @internal - * Synonym for __rw_integral_constant type. - */ +// +// Synonym for __rw_integral_constant type. +// typedef __rw_integral_constant __rw_false_type; // convenience macros Modified: stdcxx/branches/4.3.x/include/rw/_meta_other.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_other.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_other.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_other.h Tue Jul 8 16:25:19 2008 @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -56,37 +57,13 @@ #define _RWSTD_CONDITIONAL(C,T,U) _RW::__rw_conditional::type -// Helper for __rw_aligned_storage. Specializations define a member type -// that is aligned on power of two boundaries. -template <_RWSTD_SIZE_T _Align> -struct __rw_aligned_storage_impl; - -#define _RWSTD_ALIGNED_STORAGE_SPEC(N) \ - template <> struct __rw_aligned_storage_impl { \ - typedef _RWSTD_TT_ALIGNED_POD(N) _C_type; \ -} - -_RWSTD_ALIGNED_STORAGE_SPEC(1); -_RWSTD_ALIGNED_STORAGE_SPEC(2); -_RWSTD_ALIGNED_STORAGE_SPEC(4); -_RWSTD_ALIGNED_STORAGE_SPEC(8); -_RWSTD_ALIGNED_STORAGE_SPEC(16); -_RWSTD_ALIGNED_STORAGE_SPEC(32); -_RWSTD_ALIGNED_STORAGE_SPEC(64); -_RWSTD_ALIGNED_STORAGE_SPEC(128); -_RWSTD_ALIGNED_STORAGE_SPEC(256); -_RWSTD_ALIGNED_STORAGE_SPEC(512); -_RWSTD_ALIGNED_STORAGE_SPEC(1024); -_RWSTD_ALIGNED_STORAGE_SPEC(2048); -_RWSTD_ALIGNED_STORAGE_SPEC(4096); -_RWSTD_ALIGNED_STORAGE_SPEC(8192); // Helper for __rw_default_alignment. The member value will evaluate // to the nearest power of two that is a valid alignment value that // is less than or equal to _Size. template <_RWSTD_SIZE_T _Size, _RWSTD_SIZE_T _N, - bool _Done = (_RWSTD_TT_MAX_ALIGNMENT <= _N * 2) - || (_Size < _N * 2)> + bool = (_RWSTD_TT_MAX_ALIGNMENT <= _N * 2) + || (_Size < _N * 2)> struct __rw_default_alignment_impl { enum { value = __rw_default_alignment_impl<_Size, _N * 2>::value }; @@ -113,28 +90,86 @@ enum { value = __rw_default_alignment_impl<_Size, 1>::value }; }; +#ifdef __GNUG__ template <_RWSTD_SIZE_T _Size, _RWSTD_SIZE_T _Align = __rw_default_alignment<_Size>::value> struct __rw_aligned_storage { - _RWSTD_STATIC_ASSERT (_Size != 0, - "Unsupported size"); - - _RWSTD_STATIC_ASSERT ((_Align & (_Align - 1)) == 0 || _Align == 0, - "Unsupported alignment"); // expect power of 2 - - _RWSTD_STATIC_ASSERT (_Align <= _RWSTD_TT_MAX_ALIGNMENT, - "Unsupported alignment"); // expect less than max + typedef struct { + _RWSTD_TT_ALIGNED_POD (_Align) _C_align; + unsigned char _C_size [_Size]; + } type; +}; - typedef union { - unsigned char __size [_Size]; +#else // !__GNUG__ + +// Helper for __rw_aligned_storage. Specializations define a member type +// that is aligned on power of two boundaries. +template <_RWSTD_SIZE_T _Align> +struct __rw_aligned_storage_impl; + +#define _RWSTD_ALIGNED_STORAGE_SPEC(N) \ + template <> struct __rw_aligned_storage_impl { \ + typedef _RWSTD_TT_ALIGNED_POD (N) _C_type; }; + +_RWSTD_ALIGNED_STORAGE_SPEC(1) +_RWSTD_ALIGNED_STORAGE_SPEC(2) +_RWSTD_ALIGNED_STORAGE_SPEC(4) +_RWSTD_ALIGNED_STORAGE_SPEC(8) +_RWSTD_ALIGNED_STORAGE_SPEC(16) + +#if (32 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(32) +#endif + +#if (64 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(64) +#endif + +#if (128 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(128) +#endif + +#if (256 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(256) +#endif + +#if (512 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(512) +#endif + +#if (1024 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(1024) +#endif + +#if (2048 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(2048) +#endif + +#if (4096 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(4096) +#endif + +#if (8192 <= _RWSTD_TT_MAX_ALIGNMENT) + _RWSTD_ALIGNED_STORAGE_SPEC(8192) +#endif + +template <_RWSTD_SIZE_T _Size, + _RWSTD_SIZE_T _Align = __rw_default_alignment<_Size>::value> +struct __rw_aligned_storage +{ + typedef union { typename - __rw_aligned_storage_impl<_Align>::_C_type __align; + __rw_aligned_storage_impl<_Align>::_C_type _C_align; + + unsigned char _C_size [_Size]; } type; }; +#endif // !__GNUG__ + #ifndef _RWSTD_NO_VARIADIC_TEMPLATES 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=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_prop.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_prop.h Tue Jul 8 16:25:19 2008 @@ -34,7 +34,6 @@ #include #include #include -#include _RWSTD_NAMESPACE (__rw) { @@ -44,6 +43,7 @@ template <> struct Trait : __rw_true_type { }; \ template <> struct Trait : __rw_true_type { } + template struct __rw_is_const : __rw_false_type { @@ -70,153 +70,271 @@ #define _RWSTD_IS_VOLATILE(T) _RW::__rw_is_volatile::value +#if !defined(_RWSTD_TT_IS_POD) + template -struct __rw_is_standard_layout_impl +struct __rw_is_pod_impl { - typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU; - enum { _C_value = __rw_is_scalar<_TypeU>::value }; + typedef typename + __rw_remove_all_extents<_TypeT>::type _TypeU; + + typedef typename + __rw_remove_cv<_TypeU>::type _NoCV_TypeU; + + enum { _C_value = __rw_is_scalar<_NoCV_TypeU>::value }; }; +# define _RWSTD_TT_IS_POD(T) _RW::__rw_is_pod_impl::_C_value +#elif defined (_MSC_VER) + template struct __rw_is_pod_impl { - typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU; + typedef typename __rw_remove_cv<_TypeT> _TypeU; + typedef typename __rw_remove_all_extents<_TypeT>::type _TypeV; - enum { _C_value = __rw_is_scalar<_TypeU>::value -#ifdef _RWSTD_TT_IS_POD - || _RWSTD_TT_IS_POD(_TypeU) -#endif - }; + // the MSVC provided __is_pod works for pod class types only + enum { _C_value = __rw_is_scalar<_TypeV>::value + || _RWSTD_TT_IS_POD(_TypeV) }; }; +# undef _RWSTD_TT_IS_POD +# define _RWSTD_TT_IS_POD(T) _RW::__rw_is_pod_impl::_C_value +#endif // !_RWSTD_TT_IS_POD || _MSC_VER + template -struct __rw_is_empty_impl +struct __rw_is_pod + : __rw_integral_constant { - enum { _C_value = __rw_is_class<_TypeT>::value -#ifdef _RWSTD_TT_IS_EMPTY - && _RWSTD_TT_IS_EMPTY(_TypeT) -#endif - }; }; -#undef _RWSTD_TT_IS_STDANDARD_LAYOUT -#define _RWSTD_TT_IS_STDANDARD_LAYOUT(T) __rw_is_standard_layout_impl::_C_value +#define _RWSTD_IS_POD(T) _RW::__rw_is_pod::value -#ifdef _MSC_VER -# undef _RWSTD_TT_IS_POD -# define _RWSTD_TT_IS_POD(T) __rw_is_pod_impl::_C_value +#ifndef _RWSTD_TT_IS_STANDARD_LAYOUT +# define _RWSTD_TT_IS_STANDARD_LAYOUT(T) _RWSTD_TT_IS_POD(T) +#endif // _RWSTD_TT_IS_STANDARD_LAYOUT -# undef _RWSTD_TT_IS_EMPTY -# define _RWSTD_TT_IS_EMPTY(T) __rw_is_empty_impl::_C_value +template +struct __rw_is_standard_layout + : __rw_integral_constant +{ +}; -#endif // _MSC_VER +#define _RWSTD_IS_STANDARD_LAYOUT(T) _RW::__rw_is_standard_layout::value -template -struct __rw_is_standard_layout - : __rw_integral_constant + +#ifndef _RWSTD_TT_IS_EMPTY + +// +// The primary template is for the case that _TypeT is a class type. +// It checks that the size of a derived class is larger than the size +// of a non-derived class. If the sizes are the same, then _TypeT is +// assumed to be an empty class. +// +template ::value> +struct __rw_is_empty_impl { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); + struct _C_empty_1 : _TypeT { long _C_pad [32]; }; + struct _C_empty_2 { long _C_pad [32]; }; + + enum { _C_value = sizeof (_C_empty_1) == sizeof (_C_empty_2) }; }; -#define _RWSTD_IS_STANDARD_LAYOUT(T) _RW::__rw_is_standard_layout::value +// +// This specialization is for the case that _TypeT is a union or other +// non-class type. +// +template +struct __rw_is_empty_impl<_TypeT, false> +{ + enum { _C_value = 0 }; +}; +# define _RWSTD_TT_IS_EMPTY(T) _RW::__rw_is_empty_impl::_C_value +#elif defined (_MSC_VER) template -struct __rw_is_pod - : __rw_integral_constant +struct __rw_is_empty_impl<_TypeT> { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); + enum { _C_value = __rw_is_class<_TypeT>::value + && _RWSTD_TT_IS_EMPTY (_TypeT) }; }; -#define _RWSTD_IS_POD(T) _RW::__rw_is_pod::value +# undef _RWSTD_TT_IS_EMPTY +# define _RWSTD_TT_IS_EMPTY(T) _RW::__rw_is_empty_impl::_C_value +#endif // !_RWSTD_TT_IS_EMPTY || _MSC_VER template struct __rw_is_empty : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_IS_EMPTY(T) _RW::__rw_is_empty::value + + +#ifndef _RWSTD_TT_IS_POLYMORPHIC + +// +// The primary template is for the case that _TypeT is class type. +// It checks the size of a derived class against the size of a +// derived class that provides a virtual method. If the size of +// the objects are the same then we assume that _TypeT already +// has a vtbl pointer. +// +template ::value> +struct __rw_is_polymorphic_impl +{ + template + struct _C_type_1 : _TypeU + { + // only polymorphic if _TypeT is + }; + + template + struct _C_type_2 : _TypeU + { + virtual void _C_method (); + }; + + enum { _C_value = sizeof (_C_type_1<_TypeT>) + == sizeof (_C_type_2<_TypeT>) }; +}; + +// +// This specialization is for the case that _TypeT is not a class type. +// +template +struct __rw_is_polymorphic_impl<_TypeT, false> +{ + enum { _C_value = 0 }; +}; + +# define _RWSTD_TT_IS_POLYMORPHIC(T) \ + _RW::__rw_is_polymorphic_impl::_C_value +#endif // _RWSTD_TT_IS_POLYMORPHIC + template struct __rw_is_polymorphic : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_IS_POLYMORPHIC(T) _RW::__rw_is_polymorphic::value + + +#ifndef _RWSTD_TT_IS_ABSTRACT + +// +// The primary template is for the case that _TypeT is class type. +// It checks that _TypeT is an abstract type by exploiting the +// resolution to CWG#337 [http://tinyurl.com/6yltlk] +// +template ::value> +struct __rw_is_abstract_impl +{ + struct _C_no { }; + struct _C_yes { _C_no __pad[2]; }; + + template + static _C_yes _C_is (int, ...); + + template + static _C_no _C_is (int, U(*)[1]); + + enum { _C_value = sizeof (_C_yes) + == sizeof (_C_is<_TypeT>(0, 0)) }; +}; + +// +// This specialization is for the case that _TypeT is not a class type. +// +template +struct __rw_is_abstract_impl +{ + enum { _C_value = 0 }; +}; + +# define _RWSTD_TT_IS_ABSTRACT(T) _RW::__rw_is_abstract_impl::_C_value +#endif // _RWSTD_TT_IS_ABSTRACT + template struct __rw_is_abstract : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_IS_ABSTRACT(T) _RW::__rw_is_abstract::value + + +#ifndef _RWSTD_TT_HAS_TRIVIAL_CTOR + // this is just a best guess +# define _RWSTD_TT_HAS_TRIVIAL_CTOR(T) _RW::__rw_is_pod::value +#endif // _RWSTD_TT_HAS_TRIVIAL_CTOR + template struct __rw_has_trivial_ctor : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_TRIVIAL_CTOR(T) _RW::__rw_has_trivial_ctor::value + + +#ifndef _RWSTD_TT_HAS_TRIVIAL_COPY +# define _RWSTD_TT_HAS_TRIVIAL_COPY(T) \ + _RW::__rw_is_pod::value || _RW::__rw_is_reference::value +#endif // _RWSTD_TT_HAS_TRIVIAL_COPY + template struct __rw_has_trivial_copy : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_TRIVIAL_COPY(T) _RW::__rw_has_trivial_copy::value + + +#ifndef _RWSTD_TT_HAS_TRIVIAL_ASSIGN +# define _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T) \ + _RW::__rw_is_pod::value && !_RW::__rw_is_const::value \ + && !_RW::__rw_is_reference::value +#endif // _RWSTD_TT_HAS_TRIVIAL_ASSIGN + template struct __rw_has_trivial_assign : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_TRIVIAL_ASSIGN(T) _RW::__rw_has_trivial_assign::value + + +#ifndef _RWSTD_TT_HAS_TRIVIAL_DTOR +# define _RWSTD_TT_HAS_TRIVIAL_DTOR(T) \ + _RW::__rw_is_pod::value && !_RW::__rw_is_reference::value +#endif // _RWSTD_TT_HAS_TRIVIAL_DTOR + template struct __rw_has_trivial_dtor : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_TRIVIAL_DTOR(T) _RW::__rw_has_trivial_dtor::value @@ -225,76 +343,88 @@ template struct __rw_is_trivial_impl { - typedef typename __rw_remove_cv<_TypeT>::type _TypeU; - typedef typename __rw_remove_all_extents<_TypeU>::type _TypeV; + typedef typename + __rw_remove_cv<_TypeT>::type _NoCV_TypeT; - enum { _C_value = __rw_is_scalar<_TypeV>::value - || __rw_has_trivial_ctor<_TypeV>::value - && __rw_has_trivial_copy<_TypeV>::value - && __rw_has_trivial_dtor<_TypeV>::value - && __rw_has_trivial_assign<_TypeV>::value - && (__rw_is_class<_TypeV>::value || __rw_is_union<_TypeV>::value) }; + typedef typename + __rw_remove_all_extents<_NoCV_TypeT>::type _NoCV_TypeU; + + enum { _C_value = __rw_is_scalar<_NoCV_TypeU>::value + || __rw_has_trivial_ctor<_NoCV_TypeU>::value + && __rw_has_trivial_copy<_NoCV_TypeU>::value + && __rw_has_trivial_dtor<_NoCV_TypeU>::value + && __rw_has_trivial_assign<_NoCV_TypeU>::value + && ( __rw_is_class<_NoCV_TypeU>::value + || __rw_is_union<_NoCV_TypeU>::value) }; }; template struct __rw_is_trivial : __rw_integral_constant::_C_value> { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_IS_TRIVIAL(T) _RW::__rw_is_trivial::value + + +#ifndef _RWSTD_TT_HAS_NOTHROW_CTOR +# define _RWSTD_TT_HAS_NOTHROW_CTOR(T) _RW::__rw_has_trivial_ctor::value +#endif //_RWSTD_TT_HAS_NOTHROW_CTOR + template struct __rw_has_nothrow_ctor : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_NOTHROW_CTOR(T) _RW::__rw_has_nothrow_ctor::value + +#ifndef _RWSTD_TT_HAS_NOTHROW_COPY +# define _RWSTD_TT_HAS_NOTHROW_COPY(T) _RW::__rw_has_trivial_copy::value +#endif // _RWSTD_TT_HAS_NOTHROW_COPY + template struct __rw_has_nothrow_copy : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_NOTHROW_COPY(T) _RW::__rw_has_nothrow_copy::value + + +#ifndef _RWSTD_TT_HAS_NOTHROW_ASSIGN +# define _RWSTD_TT_HAS_NOTHROW_ASSIGN(T) _RW::__rw_has_trivial_assign::value +#endif // _RWSTD_TT_HAS_NOTHROW_ASSIGN + template struct __rw_has_nothrow_assign : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_NOTHROW_ASSIGN(T) _RW::__rw_has_nothrow_assign::value + +#ifndef _RWSTD_TT_HAS_VIRTUAL_DTOR +# define _RWSTD_TT_HAS_VIRTUAL_DTOR(T) _RW::__rw_is_polymorphic::value +#endif // _RWSTD_TT_HAS_VIRTUAL_DTOR + template struct __rw_has_virtual_dtor : __rw_integral_constant { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_HAS_VIRTUAL_DTOR(T) _RW::__rw_has_virtual_dtor::value + template struct __rw_is_unsigned : __rw_false_type { @@ -336,28 +466,37 @@ _RWSTD_TRAIT_SPEC_0_CV(__rw_is_unsigned, unsigned long long); #endif // _RWSTD_NO_LONG_LONG -_RWSTD_TRAIT_SPEC_0_CV(__rw_is_signed, float); -_RWSTD_TRAIT_SPEC_0_CV(__rw_is_signed, double); +#if 0 +_RWSTD_TRAIT_SPEC_0_CV(__rw_is_unsigned, char16_t); +_RWSTD_TRAIT_SPEC_0_CV(__rw_is_unsigned, char32_t); +#endif + +_RWSTD_TRAIT_SPEC_0_CV(__rw_is_signed, float); +_RWSTD_TRAIT_SPEC_0_CV(__rw_is_signed, double); #ifndef _RWSTD_NO_LONG_DOUBLE -_RWSTD_TRAIT_SPEC_0_CV(__rw_is_signed, long double); +_RWSTD_TRAIT_SPEC_0_CV(__rw_is_signed, long double); #endif // _RWSTD_NO_LONG_DOUBLE #define _RWSTD_IS_SIGNED(T) _RW::__rw_is_signed::value #define _RWSTD_IS_UNSIGNED(T) _RW::__rw_is_unsigned::value + +#ifndef _RWSTD_TT_ALIGN_OF +# define _RWSTD_TT_ALIGN_OF(T) 0 +#endif // _RWSTD_TT_ALIGN_OF + template struct __rw_alignment_of : __rw_integral_constant<_RWSTD_SIZE_T, _RWSTD_TT_ALIGN_OF(_TypeT)> { - //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) - // || _RWSTD_IS_ARRAY (_TypeT) - // || _RWSTD_IS_VOID (_TypeT)); }; #define _RWSTD_ALIGNMENT_OF(T) _RW::__rw_alignment_of::value + + template struct __rw_rank : __rw_integral_constant<_RWSTD_SIZE_T, 0> @@ -379,6 +518,7 @@ #define _RWSTD_RANK(T) _RW::__rw_rank::value + template struct __rw_extent : __rw_integral_constant<_RWSTD_SIZE_T, 0> @@ -387,13 +527,15 @@ template struct __rw_extent<_TypeT [_Size], _Depth> - : __rw_integral_constant<_RWSTD_SIZE_T, __rw_extent<_TypeT, _Depth - 1>::value> + : __rw_integral_constant<_RWSTD_SIZE_T, + __rw_extent<_TypeT, _Depth - 1>::value> { }; template struct __rw_extent<_TypeT [], _Depth> - : __rw_integral_constant<_RWSTD_SIZE_T, __rw_extent<_TypeT, _Depth - 1>::value> + : __rw_integral_constant<_RWSTD_SIZE_T, + __rw_extent<_TypeT, _Depth - 1>::value> { }; Modified: stdcxx/branches/4.3.x/include/rw/_meta_ref.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_ref.h?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_ref.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_ref.h Tue Jul 8 16:25:19 2008 @@ -83,17 +83,18 @@ { // for rval reference types, _C_type shall become the corresponding // lvalue reference type - typedef _TYPENAME __rw_remove_reference<_TypeT>::type& _C_type; + typedef typename __rw_remove_reference<_TypeT>::type& _C_type; }; template struct __rw_add_lvalue_reference { - typedef _TYPENAME + typedef typename __rw_add_lvalue_reference_impl<_TypeT>::_C_type type; }; -#define _RWSTD_ADD_LVALUE_REFERENCE(T) _RW::__rw_add_lvalue_reference::type +#define _RWSTD_ADD_LVALUE_REFERENCE(T) \ + _RW::__rw_add_lvalue_reference::type template ::value @@ -121,11 +122,12 @@ template struct __rw_add_rvalue_reference { - typedef _TYPENAME + typedef typename __rw_add_rvalue_reference_impl<_TypeT>::_C_type type; }; -#define _RWSTD_ADD_RVALUE_REFERENCE(T) _RW::__rw_add_rvalue_reference::type +#define _RWSTD_ADD_RVALUE_REFERENCE(T) \ + _RW::__rw_add_rvalue_reference::type } // namespace __rw 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=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_rel.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_rel.h Tue Jul 8 16:25:19 2008 @@ -32,11 +32,18 @@ #include -#include -#include -#include -#include -#include +#ifndef _RWSTD_TT_IS_CONVERTIBLE +# include +# include +# include +# include +# include +#endif // _RWSTD_TT_IS_CONVERTIBLE + +#ifndef _RWSTD_TT_IS_BASE_OF +# include +# include +#endif //_RWSTD_TT_IS_BASE_OF _RWSTD_NAMESPACE (__rw) { @@ -52,40 +59,98 @@ #define _RWSTD_IS_SAME(T,U) _RW::__rw_is_same::value -template -struct __rw_is_base_of - : __rw_integral_constant -{ - //_RWSTD_ASSERT ( _RWSTD_IS_CLASS (_TypeT) - // && _RWSTD_IS_CLASS (_TypeU) - // && !_RWSTD_IS_SAME(_TypeT, _TypeU) - // || -}; - -#define _RWSTD_IS_BASE_OF(T,U) _RW::__rw_is_base_of::value -template +template struct __rw_is_convertible_impl { struct _C_no { }; struct _C_yes { _C_no __pad [2]; }; - static _C_yes _C_is (int, _TypeU); - static _C_no _C_is (int, ...); + struct _Dummy + { + template + _Dummy (_Anything); + }; + + template + static _C_no _C_is (_Dummy, _TypeT); + static _C_yes _C_is (_To, int); - static _TypeT _C_make (); + static _From _C_make (); - enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (0, _C_make ())) }; + enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (_C_make (), 0)) }; }; +#ifndef _RWSTD_TT_IS_BASE_OF + +// +// This fallback tests if a pointer to _Base is convertible to a +// pointer of _Derived after both types have been cv-stripped. +// +// This little gem was taken from a comp.lang.c++.moderated post +// by Rani Sharoni [see http://tinyurl.com/6pdv3k] +// +template ::value + && __rw_is_class<_Derived>::value> +struct __rw_is_base_of_impl +{ + typedef typename __rw_remove_cv<_Derived>::type _NoCV_Derived; + typedef typename __rw_remove_cv<_Base>::type _NoCV_Base; + + struct _C_no { }; + struct _C_yes { _C_no __pad [2]; }; + + template + static _C_yes _C_is (_NoCV_Derived&, _TypeT); + static _C_no _C_is (_NoCV_Base& , int); + + struct _C_nest + { + operator _NoCV_Base& () const; + operator _NoCV_Derived& (); + }; + + static _C_nest _C_make (); + + enum { _C_value = + __rw_is_same<_NoCV_Base, _NoCV_Derived>::value + || sizeof (_C_yes) == sizeof (_C_is (_C_make (), 0)) }; +}; + +// +// +// +template +struct __rw_is_base_of_impl<_Base, _Derived, false> +{ + enum { _C_value = 0 }; +}; + +# define _RWSTD_TT_IS_BASE_OF(T,U) \ + _RW::__rw_is_base_of_impl::_C_value +#endif // _RWSTD_TT_IS_BASE_OF +template +struct __rw_is_base_of + : __rw_integral_constant +{ + //_RWSTD_ASSERT ( _RWSTD_IS_CLASS (_Base) + // && _RWSTD_IS_CLASS (_Derived) + // && !_RWSTD_IS_SAME(_Base, _Derived) + // || +}; + +#define _RWSTD_IS_BASE_OF(T,U) _RW::__rw_is_base_of::value -template ::value, - bool = __rw_is_function<_TypeT>::value> +#ifndef _RWSTD_TT_IS_CONVERTIBLE +template ::value, + bool = __rw_is_function<_TypeT>::value> struct __rw_is_convertible_3 { // _TypeT is neither an array nor a function type, so just do a @@ -94,28 +159,31 @@ }; template -struct __rw_is_convertible_3<_TypeT,_TypeU,true,false> +struct __rw_is_convertible_3<_TypeT, _TypeU, true, false> { // _TypeT is an array type, see if we can convert it to a _TypeU* - typedef _TYPENAME __rw_remove_extent<_TypeT>::type _TypeV; - typedef _TYPENAME __rw_add_pointer<_TypeV>::type _TypeT_Ptr; + typedef typename __rw_remove_extent<_TypeT>::type _TypeV; + typedef typename __rw_add_pointer<_TypeV>::type _TypeT_Ptr; - enum { _C_value = __rw_is_convertible_impl<_TypeT_Ptr, _TypeU>::_C_value }; + enum { _C_value = + __rw_is_convertible_impl<_TypeT_Ptr, _TypeU>::_C_value }; }; template -struct __rw_is_convertible_3<_TypeT,_TypeU,false,true> +struct __rw_is_convertible_3<_TypeT, _TypeU, false, true> { // _TypeT is an function type, try to convert to reference or pointer - typedef _TYPENAME __rw_add_lvalue_reference<_TypeT>::type _TypeT_Ref; - typedef _TYPENAME __rw_add_pointer<_TypeT>::type _TypeT_Ptr; + typedef typename __rw_add_lvalue_reference<_TypeT>::type _TypeT_Ref; + typedef typename __rw_add_pointer<_TypeT>::type _TypeT_Ptr; - enum { _C_value = __rw_is_convertible_impl<_TypeT_Ref, _TypeU>::_C_value - || __rw_is_convertible_impl<_TypeT_Ptr, _TypeU>::_C_value }; + enum { _C_value = + __rw_is_convertible_impl<_TypeT_Ref, _TypeU>::_C_value + || __rw_is_convertible_impl<_TypeT_Ptr, _TypeU>::_C_value }; }; -template ::value - ||__rw_is_function<_TypeU>::value> +template ::value + || __rw_is_function<_TypeU>::value> struct __rw_is_convertible_2 { // _TypeU is neither an array nor a function type @@ -152,14 +220,13 @@ enum { _C_value = 1 }; }; +# define _RWSTD_TT_IS_CONVERTIBLE(T,U) \ + _RW::__rw_is_convertible_1::_C_value +#endif // _RWSTD_TT_IS_CONVERTIBLE + template struct __rw_is_convertible -#ifdef _RWSTD_TT_IS_CONVERTIBLE : __rw_integral_constant -#else - : __rw_integral_constant::_C_value> -#endif { //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT) // || _RWSTD_IS_ARRAY (_TypeT) 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=675050&r1=675049&r2=675050&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 Tue Jul 8 16:25:19 2008 @@ -180,11 +180,11 @@ TEST (std::is_base_of, struct_A, struct_A, true); TEST (std::is_base_of, derived_, - derived_, true); + derived_, true); TEST (std::is_base_of, class_B, class_B, true); TEST (std::is_base_of, derived_, - derived_, true); + derived_, true); TEST (std::is_base_of, union_C, union_C, false); @@ -193,10 +193,10 @@ TEST (std::is_base_of, class_B, derived_, true); // protected inheritance - TEST (std::is_base_of, derived_protected_ , struct_A , true); + TEST (std::is_base_of, struct_A, derived_protected_, true); // private inheritance - TEST (std::is_base_of, derived_private_ , struct_A , true); + TEST (std::is_base_of, struct_A, derived_private_, true); // other combinations should fail TEST (std::is_base_of, signed char, char, false); Modified: stdcxx/branches/4.3.x/tests/utilities/20.meta.trans.other.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.meta.trans.other.cpp?rev=675050&r1=675049&r2=675050&view=diff ============================================================================== --- stdcxx/branches/4.3.x/tests/utilities/20.meta.trans.other.cpp (original) +++ stdcxx/branches/4.3.x/tests/utilities/20.meta.trans.other.cpp Tue Jul 8 16:25:19 2008 @@ -38,6 +38,7 @@ #include // for rwsprintfa() #include // for free() +#include // for size_t /**************************************************************************/ @@ -157,7 +158,8 @@ { \ typedef std::aligned_storage::type storage_t; \ test_aligned_storage(__LINE__, \ - Size, sizeof (storage_t), Align, __alignof (storage_t)); \ + Size, sizeof (storage_t), Align, \ + std::alignment_of::value); \ } typedef void __dummy TEST (1, 1); @@ -180,18 +182,19 @@ { \ typedef std::aligned_storage::type storage_t; \ test_aligned_storage(__LINE__, \ - Size, sizeof (storage_t), 0, __alignof (storage_t)); \ + Size, sizeof (storage_t), 0, \ + std::alignment_of::value); \ } typedef void __dummy // test default alignment TEST (1); - TEST (1); - TEST (1); - TEST (1); - - TEST (9); - TEST (9); - TEST (9); + TEST (2); + TEST (4); + TEST (8); + + TEST (3); + TEST (5); + TEST (7); TEST (9); TEST (55); @@ -476,4 +479,3 @@ 0); } -