You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by vi...@apache.org on 2008/08/01 22:51:22 UTC
svn commit: r681820 [3/7] - in /stdcxx/trunk: ./ doc/ etc/config/src/
examples/include/ include/ include/loc/ include/rw/ src/ tests/containers/
tests/diagnostics/ tests/include/ tests/intro/ tests/localization/
tests/regress/ tests/src/ tests/strings/...
Modified: stdcxx/trunk/include/rw/_iterbase.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_iterbase.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_iterbase.h (original)
+++ stdcxx/trunk/include/rw/_iterbase.h Fri Aug 1 13:51:17 2008
@@ -57,11 +57,11 @@
template <class _Iterator>
struct iterator_traits
{
- typedef _TYPENAME _Iterator::value_type value_type;
- typedef _TYPENAME _Iterator::difference_type difference_type;
- typedef _TYPENAME _Iterator::pointer pointer;
- typedef _TYPENAME _Iterator::reference reference;
- typedef _TYPENAME _Iterator::iterator_category iterator_category;
+ typedef typename _Iterator::value_type value_type;
+ typedef typename _Iterator::difference_type difference_type;
+ typedef typename _Iterator::pointer pointer;
+ typedef typename _Iterator::reference reference;
+ typedef typename _Iterator::iterator_category iterator_category;
};
@@ -128,7 +128,7 @@
__iterator_category (const iterator<_Category, _TypeT,
_Distance, _Pointer, _Reference>&)
{
- typedef _TYPENAME iterator<_Category, _TypeT, _Distance, _TypeT*,
+ typedef typename iterator<_Category, _TypeT, _Distance, _TypeT*,
_TypeT&>::iterator_category _IterCategory;
return _IterCategory ();
@@ -187,7 +187,7 @@
#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
template <class _Iterator>
-inline _TYPENAME iterator_traits<_Iterator>::value_type*
+inline typename iterator_traits<_Iterator>::value_type*
__value_type (const _Iterator*)
{
return 0;
@@ -216,7 +216,7 @@
#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
template <class _Iterator>
-inline _TYPENAME iterator_traits<_Iterator>::difference_type*
+inline typename iterator_traits<_Iterator>::difference_type*
__distance_type (_Iterator)
{
return 0;
@@ -337,10 +337,10 @@
// 24.3.4, p4
template <class _ForwardIterator>
-inline _TYPENAME iterator_traits<_ForwardIterator>::difference_type
+inline typename iterator_traits<_ForwardIterator>::difference_type
distance (_ForwardIterator __first, _ForwardIterator __last)
{
- _TYPENAME iterator_traits<_ForwardIterator>::difference_type __n = 0;
+ typename iterator_traits<_ForwardIterator>::difference_type __n = 0;
__distance (__first, __last, __n,
_RWSTD_ITERATOR_CATEGORY (_ForwardIterator, __first));
@@ -408,11 +408,11 @@
public:
- typedef _TYPENAME traits_type::value_type value_type;
- typedef _TYPENAME traits_type::difference_type difference_type;
- typedef _TYPENAME traits_type::reference reference;
- typedef _TYPENAME traits_type::pointer pointer;
- typedef _TYPENAME traits_type::iterator_category iterator_category;
+ typedef typename traits_type::value_type value_type;
+ typedef typename traits_type::difference_type difference_type;
+ typedef typename traits_type::reference reference;
+ typedef typename traits_type::pointer pointer;
+ typedef typename traits_type::iterator_category iterator_category;
typedef __rw_debug_iter <container_type, _MutableIterator,
_MutableIterator> _C_mutable_iterator;
@@ -511,8 +511,7 @@
return _C_iter;
}
-#if !defined (_RWSTD_NO_MEMBER_TEMPLATES) \
- && (!defined (__IBMCPP__) || __IBMCPP__ > 502)
+#if !defined (__IBMCPP__) || __IBMCPP__ > 502
// IBM xlC 5.0 fails to find these member template operators,
// yet it complains about ambiguity if they are defined along
@@ -570,7 +569,7 @@
return !(_C_iter < __rhs._C_iter);
}
-#endif // !_RWSTD_NO_MEMBER_TEMPLATES && __IBMCPP__ > 502
+#endif // __IBMCPP__ > 502
iterator_type _C_iter; // wrapped iterator
const container_type *_C_cont; // associated container
@@ -584,7 +583,7 @@
#ifndef _RWSTD_NO_NONDEDUCED_CONTEXT
-# define _RWSTD_CONT_DIFF_TYPE _TYPENAME _Cont::difference_type
+# define _RWSTD_CONT_DIFF_TYPE typename _Cont::difference_type
#else
# define _RWSTD_CONT_DIFF_TYPE _RWSTD_PTRDIFF_T
#endif
@@ -600,8 +599,7 @@
#undef _RWSTD_CONT_DIFF_TYPE
-#if defined (_RWSTD_NO_MEMBER_TEMPLATES) \
- || defined (__IBMCPP__) && __IBMCPP__ <= 502
+#if defined (__IBMCPP__) && __IBMCPP__ <= 502
// IBM xlC 5.0 fails to find the member template operators
// defined above in the presence of namespaces...
@@ -615,7 +613,7 @@
// and non-const iterators, respectively (allows symmetry)
template <class _Cont, class _Iter1, class _Iter2, class _MutIter>
-inline _TYPENAME _Cont::difference_type
+inline typename _Cont::difference_type
operator- (const _RW::__rw_debug_iter<_Cont, _Iter1, _MutIter> &__x,
const _RW::__rw_debug_iter<_Cont, _Iter2, _MutIter> &__y)
{
@@ -672,7 +670,7 @@
return __y < __x;
}
-#endif // _RWSTD_NO_MEMBER_TEMPLATES && __IBMCPP__ <= 502
+#endif // __IBMCPP__ <= 502
} // namespace std
Modified: stdcxx/trunk/include/rw/_meta_arr.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_arr.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_arr.h (original)
+++ stdcxx/trunk/include/rw/_meta_arr.h Fri Aug 1 13:51:17 2008
@@ -34,74 +34,53 @@
_RWSTD_NAMESPACE (__rw) {
-/**
- * TransformationTrait strips one dimension from an array type, leaving
- * other types as-is. The primary template is for non-array types.
- */
template <class _TypeT>
struct __rw_remove_extent
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips one dimension from an array type, leaving
- * other types as-is. This specialization is for array types of bounded
- * size.
- */
template <class _TypeT, _RWSTD_SIZE_T _Size>
struct __rw_remove_extent<_TypeT [_Size]>
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips one dimension from an array type, leaving
- * other types as-is. This specialization is for array types of unbounded
- * size.
- */
+#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
+
template <class _TypeT>
struct __rw_remove_extent<_TypeT []>
{
typedef _TypeT type;
};
-//#define _RWSTD_REMOVE_EXTENT(T) _RW::__rw_remove_extent<T>::type
+#endif
+
+#define _RWSTD_REMOVE_EXTENT(T) _RW::__rw_remove_extent<T>::type
-/**
- * TransformationTrait strips one dimension from an array type, leaving
- * other types as-is. The primary template is for non-array types. The
- * member typedef type will be the same as _TypeT.
- */
template <class _TypeT>
struct __rw_remove_all_extents
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips all dimensions from an array type, leaving
- * other types as-is. This specialization is for array types of bounded
- * size.
- */
template <class _TypeT, _RWSTD_SIZE_T _Size>
struct __rw_remove_all_extents<_TypeT [_Size]>
{
typedef typename __rw_remove_all_extents<_TypeT>::type type;
};
-/**
- * TransformationTrait strips one dimension from an array type, leaving
- * other types as-is. This specialization is for array types of unbounded
- * size.
- */
+#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
+
template <class _TypeT>
struct __rw_remove_all_extents<_TypeT []>
{
typedef typename __rw_remove_all_extents<_TypeT>::type type;
};
-//#define _RWSTD_REMOVE_ALL_EXTENTS(T) _RW::__rw_remove_all_extents<T>::type
+#endif
+
+#define _RWSTD_REMOVE_ALL_EXTENTS(T) _RW::__rw_remove_all_extents<T>::type
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_cat.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_cat.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_cat.h (original)
+++ stdcxx/trunk/include/rw/_meta_cat.h Fri Aug 1 13:51:17 2008
@@ -66,10 +66,6 @@
struct Trait<Type const volatile> \
: __rw_integral_constant<bool, Cond> { }
-/**
- * UnaryTypeTrait to determine if _TypeT is a (potentially cv-qualified)
- * void type.
- */
template <class _TypeT>
struct __rw_is_void : __rw_false_type
{
@@ -77,15 +73,9 @@
_RWSTD_TRAIT_SPEC_0_CV(__rw_is_void, void, true);
-#define _RWSTD_IS_VOID(T) \
- _RW::__rw_is_void<T>::value
+#define _RWSTD_IS_VOID(T) _RW::__rw_is_void<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is a (potentially cv-qualified)
- * integral type. Integral types include bool, char, wchar_t and all of
- * the signed and unsigned integer types.
- */
template <class _TypeT>
struct __rw_is_integral : __rw_false_type
{
@@ -117,14 +107,8 @@
_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, unsigned long long, true);
#endif // _RWSTD_NO_LONG_LONG
-#define _RWSTD_IS_INTEGRAL(T) \
- _RW::__rw_is_integral<T>::value
+#define _RWSTD_IS_INTEGRAL(T) _RW::__rw_is_integral<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is a (potentially cv-qualified)
- * floating point type. The floating point types include float, double
- * and long double.
- */
template <class _TypeT>
struct __rw_is_floating_point : __rw_false_type
{
@@ -137,13 +121,9 @@
_RWSTD_TRAIT_SPEC_0_CV(__rw_is_floating_point, long double, true);
#endif // _RWSTD_NO_LONG_DOUBLE
-#define _RWSTD_IS_FLOATING_POINT(T) \
- _RW::__rw_is_floating_point<T>::value
+#define _RWSTD_IS_FLOATING_POINT(T) _RW::__rw_is_floating_point<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is an array type.
- */
template <class _TypeT>
struct __rw_is_array : __rw_false_type
{
@@ -154,18 +134,17 @@
{
};
+#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
+
template <class _TypeT>
struct __rw_is_array<_TypeT []> : __rw_true_type
{
};
-#define _RWSTD_IS_ARRAY(T) \
- _RW::__rw_is_array<T>::value
+#endif
+
+#define _RWSTD_IS_ARRAY(T) _RW::__rw_is_array<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is a (potentially cv-qualified)
- * pointer type.
- */
template <class _TypeT>
struct __rw_is_pointer : __rw_false_type
{
@@ -173,13 +152,9 @@
_RWSTD_TRAIT_SPEC_1_CV(__rw_is_pointer, _TypeT*, true);
-#define _RWSTD_IS_POINTER(T) \
- _RW::__rw_is_pointer<T>::value
+#define _RWSTD_IS_POINTER(T) _RW::__rw_is_pointer<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is a lval reference type.
- */
template <class _TypeT>
struct __rw_is_lvalue_reference : __rw_false_type
{
@@ -190,12 +165,10 @@
{
};
-#define _RWSTD_IS_LVAL_REF(T) \
- _RW::__rw_is_lval_ref<T>::value
+#define _RWSTD_IS_LVALUE_REFERENCE(T) \
+ _RW::__rw_is_lvalue_reference<T>::value
+
-/**
- * UnaryTypeTrait to determine if _TypeT is a rval reference type.
- */
template <class _TypeT>
struct __rw_is_rvalue_reference : __rw_false_type
{
@@ -211,72 +184,133 @@
#endif // _RWSTD_NO_RVALUE_REFERENCES
-#define _RWSTD_IS_RVAL_REF(T) \
- _RW::__rw_is_rval_ref<T>::value
+#define _RWSTD_IS_RVALUE_REFERENCE(T) \
+ _RW::__rw_is_rvalue_reference<T>::value
+
+
-/**
- * Class template can be used to determine if _TypeT is an enumeration.
- */
template <class _TypeT>
-struct __rw_is_enum
- : __rw_integral_constant<bool, _RWSTD_TT_IS_ENUM(_TypeT)>
+struct __rw_is_class_or_union
{
+ struct _C_no { };
+ struct _C_yes { _C_no __pad[2]; };
+
+ template <class _TypeU>
+ static _C_yes _C_is (int, long _TypeU::*);
+
+ template <class _TypeU>
+ static _C_no _C_is (int, ...);
+
+ enum { value =
+ sizeof (_C_yes) == sizeof (_C_is<_TypeT>(0, 0))
+ };
};
-#define _RWSTD_IS_ENUM(T) \
- _RW::__rw_is_enum<T>::value
+#if defined (_RWSTD_TT_IS_UNION)
+# define _RWSTD_IS_UNION(T) _RWSTD_TT_IS_UNION(T)
+#elif defined (_RWSTD_TT_IS_CLASS)
+# define _RWSTD_IS_UNION(T) \
+ _RW::__rw_is_class_or_union<T>::value && !_RWSTD_TT_IS_CLASS(T)
+#else
+# define _RWSTD_IS_UNION(T) 0
+#endif
-/**
- * UnaryTypeTrait to determine if _TypeT is a union type.
- */
template <class _TypeT>
struct __rw_is_union
- : __rw_integral_constant<bool, _RWSTD_TT_IS_UNION(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_IS_UNION(_TypeT)>
{
};
-#define _RWSTD_IS_UNION(T) \
- _RW::__rw_is_union<T>::value
+#if defined (_RWSTD_TT_IS_CLASS)
+# define _RWSTD_IS_CLASS(T) _RWSTD_TT_IS_CLASS(T)
+#elif defined (_RWSTD_TT_IS_UNION)
+# define _RWSTD_IS_CLASS(T) \
+ _RW::__rw_is_class_or_union<T>::value && !_RWSTD_TT_IS_UNION(T)
+#else
+# define _RWSTD_IS_CLASS(T) _RW::__rw_is_class_or_union<T>::value
+#endif
-/**
- * UnaryTypeTrait to determine if _TypeT is a class type.
- */
template <class _TypeT>
struct __rw_is_class
- : __rw_integral_constant<bool, _RWSTD_TT_IS_CLASS(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_IS_CLASS(_TypeT)>
{
};
-#define _RWSTD_IS_CLASS(T) \
- _RW::__rw_is_class<T>::value
-/**
- * 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.
- *
- * All void, array and reference types are not functions.
- */
+#ifdef _RWSTD_TT_IS_ENUM
+# define _RWSTD_IS_ENUM(T) _RWSTD_TT_IS_ENUM(T)
+#else
+
template <class _TypeT, bool = __rw_is_void<_TypeT>::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_rvalue_reference<_TypeT>::value
+ || __rw_is_class_or_union<_TypeT>::value>
+struct __rw_is_enum_impl
+{
+ enum { _C_value = 0 };
+};
+
+template <class _TypeT>
+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_IS_ENUM(T) _RW::__rw_is_enum_impl<T>::_C_value
+#endif // !_RWSTD_TT_IS_ENUM
+
+template <class _TypeT>
+struct __rw_is_enum
+ : __rw_integral_constant<bool, _RWSTD_IS_ENUM(_TypeT)>
+{
+};
+
+
+
+#ifdef _RWSTD_TT_IS_FUNCTION
+# define _RWSTD_IS_FUNCTION(T) _RWSTD_TT_IS_FUNCTION(T)
+#else
+
+//
+// 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 <class _TypeT, bool = __rw_is_void<_TypeT>::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_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.
- */
+//
+// 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 <class _TypeT>
struct __rw_is_function_impl<_TypeT, false>
{
@@ -286,34 +320,26 @@
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 <class _TypeU>
+ 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 ())) };
};
-/**
- * UnaryTypeTrait to determine if _TypeT is a function type.
- */
+# define _RWSTD_IS_FUNCTION(T) _RW::__rw_is_function_impl<T>::_C_value
+#endif //_RWSTD_TT_IS_FUNCTION
+
template <class _TypeT>
struct __rw_is_function
-#ifdef _RWSTD_TT_IS_FUNCTION
- : __rw_integral_constant<bool, _RWSTD_TT_IS_FUNCTION(_TypeT)>
-#else
- : __rw_integral_constant<bool, __rw_is_function_impl<_TypeT>::_C_value>
-#endif // _RWSTD_TT_IS_FUNCTION
+ : __rw_integral_constant<bool, _RWSTD_IS_FUNCTION(_TypeT)>
{
};
-#define _RWSTD_IS_FUNCTION(T) \
- _RW::__rw_is_function<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is a pointer to member
- * object type.
- */
template <class _TypeT>
struct __rw_is_member_object_pointer : __rw_false_type
{
@@ -323,13 +349,10 @@
_TypeT _ClassT::*,
!__rw_is_function<_TypeT>::value);
-#define _RWSTD_IS_MEMOBJ_PTR(T) \
+#define _RWSTD_IS_MEMBER_OBJECT_PTR(T) \
_RW::__rw_is_member_object_pointer<T>::value
-/**
- * UnaryTypeTrait to determine if _TypeT is a pointer to member
- * function type.
- */
+
template <class _TypeT>
struct __rw_is_member_function_pointer : __rw_false_type
{
@@ -339,7 +362,7 @@
_TypeT _ClassT::*,
__rw_is_function<_TypeT>::value);
-#define _RWSTD_IS_MEMFUN_PTR(T) \
+#define _RWSTD_IS_MEMBER_FUNCTION_PTR(T) \
_RW::__rw_is_member_function_pointer<T>::value
#undef _RWSTD_TRAIT_SPEC_2_CV
Modified: stdcxx/trunk/include/rw/_meta_comp.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_comp.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_comp.h (original)
+++ stdcxx/trunk/include/rw/_meta_comp.h Fri Aug 1 13:51:17 2008
@@ -35,36 +35,26 @@
_RWSTD_NAMESPACE (__rw) {
-/**
- * UnaryTypeTrait indicates that _TypeT is either a lval or
- * rval reference type.
- */
template <class _TypeT>
struct __rw_is_reference
- : __rw_integral_constant<bool, __rw_is_lvalue_reference<_TypeT>::value
- || __rw_is_rvalue_reference<_TypeT>::value>
+ : __rw_integral_constant<bool,
+ __rw_is_lvalue_reference<_TypeT>::value
+ || __rw_is_rvalue_reference<_TypeT>::value>
{
};
-/**
- * UnaryTypeTrait indicates that _TypeT is an arithmethic type.
- *
- * The arithmetic types include all integral and floating point
- * types.
- */
+#define _RWSTD_IS_REFERENCE(T) _RW::__rw_is_reference<T>::value
+
template <class _TypeT>
struct __rw_is_arithmetic
- : __rw_integral_constant<bool, __rw_is_integral<_TypeT>::value
- || __rw_is_floating_point<_TypeT>::value>
+ : __rw_integral_constant<bool,
+ __rw_is_integral<_TypeT>::value
+ || __rw_is_floating_point<_TypeT>::value>
{
};
-/**
- * UnaryTypeTrait indicates that _TypeT is an fundamental type.
- *
- * The fundamental types include void and all of the standard
- * arithmetic types.
- */
+#define _RWSTD_IS_ARITHMETIC(T) _RW::__rw_is_arithmetic<T>::value
+
template <class _TypeT>
struct __rw_is_fundamental
: __rw_integral_constant<bool, __rw_is_void<_TypeT>::value
@@ -72,13 +62,9 @@
{
};
+#define _RWSTD_IS_FUNDAMENTAL(T) _RW::__rw_is_fundamental<T>::value
+
-/**
- * UnaryTypeTrait indicates that _TypeT is an object type.
- *
- * An object is a (possibly cv-qualified) type that is not a
- * function type, not a reference type, and not a void type.
- */
template <class _TypeT>
struct __rw_is_object
: __rw_integral_constant<bool, !__rw_is_function<_TypeT>::value
@@ -87,27 +73,19 @@
{
};
-/**
- * UnaryTypeTrait indicates that _TypeT is a member pointer type.
- *
- * The member pointer types include pointers to member functions and
- * pointer to member data. Neither pointers to static member functions
- * or pointers to static member data are included.
- */
+#define _RWSTD_IS_OBJECT(T) _RW::__rw_is_object<T>::value
+
+
template <class _TypeT>
struct __rw_is_member_pointer
- : __rw_integral_constant<bool, __rw_is_member_function_pointer<_TypeT>::value
- || __rw_is_member_object_pointer<_TypeT>::value>
+ : __rw_integral_constant<bool,
+ __rw_is_member_function_pointer<_TypeT>::value
+ || __rw_is_member_object_pointer<_TypeT>::value>
{
};
-/**
- * UnaryTypeTrait indicates that _TypeT is a scalar type.
- *
- * The scalar types include arithmetic types, enumeration types,
- * pointer types, pointer to member types, std::nullptr_t and
- * cv-qualified versions of these types.
- */
+#define _RWSTD_IS_MEMBER_POINTER(T) _RW::__rw_is_member_pointer<T>::value
+
template <class _TypeT>
struct __rw_is_scalar
: __rw_integral_constant<bool, __rw_is_arithmetic<_TypeT>::value
@@ -115,19 +93,14 @@
|| __rw_is_pointer<_TypeT>::value
|| __rw_is_member_pointer<_TypeT>::value>
{
- /**
- * todo need to handle special case
- *
- * __rw_is_same<std::nullptr_t, __rw_remove_cv<_TypeT>::type>::value
- */
+ // todo need to handle special case
+ //
+ // __rw_is_same<std::nullptr_t, __rw_remove_cv<_TypeT>::type>::value
};
-/**
- * UnaryTypeTrait indicates that _TypeT is a compound type.
- *
- * The compound types include arrays, functions, pointers, references,
- * classes, unions, enumerations, pointer to non-static class members
- */
+#define _RWSTD_IS_SCALAR(T) _RW::__rw_is_scalar<T>::value
+
+
template <class _TypeT>
struct __rw_is_compound
: __rw_integral_constant<bool, __rw_is_array<_TypeT>::value
@@ -141,6 +114,9 @@
{
};
+#define _RWSTD_IS_COMPOUND(T) _RW::__rw_is_compound<T>::value
+
+
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_cv.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_cv.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_cv.h (original)
+++ stdcxx/trunk/include/rw/_meta_cv.h Fri Aug 1 13:51:17 2008
@@ -36,54 +36,35 @@
_RWSTD_NAMESPACE (__rw) {
-/**
- * TransformationTrait strips any top level const-qualifier from _TypeT.
- *
- * The primary template is for non-const types.
- */
template <class _TypeT>
struct __rw_remove_const
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips any top level const-qualifier from _TypeT.
- *
- * This specialization is for const types.
- */
template <class _TypeT>
struct __rw_remove_const<const _TypeT>
{
typedef _TypeT type;
};
+#define _RWSTD_REMOVE_CONST(T) _RW::__rw_remove_const<T>::type
+
-/**
- * TransformationTrait strips any top level volatile-qualifier from _TypeT.
- *
- * The primary template is for non-volatile types.
- */
template <class _TypeT>
struct __rw_remove_volatile
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips any top level volatile-qualifier from _TypeT.
- *
- * This specialization is for volatile types.
- */
template <class _TypeT>
struct __rw_remove_volatile<volatile _TypeT>
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips top level cv-qualifiers from _TypeT.
- */
+#define _RWSTD_REMOVE_VOLATILE(T) _RW::__rw_remove_volatile<T>::type
+
template <class _TypeT>
struct __rw_remove_cv
{
@@ -92,6 +73,9 @@
>::type type;
};
+#define _RWSTD_REMOVE_CV(T) _RW::__rw_remove_cv<T>::type
+
+
template <class _TypeT, bool = __rw_is_function<_TypeT>::value
|| __rw_is_reference<_TypeT>::value>
struct __rw_add_const_impl
@@ -105,19 +89,14 @@
typedef const _TypeT _C_type;
};
-/**
- * TransformationTrait adds a top level const qualifier to _TypeT.
- *
- * If _TypeT is a reference, function, or top-level const-qualified
- * type, then type shall name the same type as _TypeT otherwise it
- * shall name const _TypeT.
- */
template <class _TypeT>
struct __rw_add_const
{
typedef typename __rw_add_const_impl<_TypeT>::_C_type type;
};
+#define _RWSTD_ADD_CONST(T) _RW::__rw_add_const<T>::type
+
template <class _TypeT, bool = __rw_is_function<_TypeT>::value
|| __rw_is_reference<_TypeT>::value>
@@ -132,22 +111,15 @@
typedef volatile _TypeT _C_type;
};
-/**
- * TransformationTrait adds a top level volatile qualifier to _TypeT.
- *
- * If _TypeT is a reference, function, or top-level volatile-qualified
- * type, then type shall name the same type as _TypeT otherwise it
- * shall name volatile _TypeT.
- */
template <class _TypeT>
struct __rw_add_volatile
{
typedef typename __rw_add_volatile_impl<_TypeT>::_C_type type;
};
-/**
- * Trait adds top level cv-qualifiers to _TypeT.
- */
+#define _RWSTD_ADD_VOLATILE(T) _RW::__rw_add_volatile<T>::type
+
+
template <class _TypeT>
struct __rw_add_cv
{
@@ -157,6 +129,8 @@
>::type type;
};
+#define _RWSTD_ADD_CV(T) _RW::__rw_add_cv<T>::type
+
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_help.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_help.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_help.h (original)
+++ stdcxx/trunk/include/rw/_meta_help.h Fri Aug 1 13:51:17 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 <class _TypeT, _TypeT _Value>
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,18 +54,20 @@
#endif // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
-/**
- * @internal
- * Synonym for __rw_integral_constant<bool, true> type.
- */
+//
+// Synonym for __rw_integral_constant<bool, true> type.
+//
typedef __rw_integral_constant<bool, true> __rw_true_type;
-/**
- * @internal
- * Synonym for __rw_integral_constant<bool, false> type.
- */
+//
+// Synonym for __rw_integral_constant<bool, false> type.
+//
typedef __rw_integral_constant<bool, false> __rw_false_type;
+// convenience macros
+
+#define _RWSTD_BOOL_CONST(B) _RW::__rw_integral_constant<bool, B>
+
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_other.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_other.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_other.h (original)
+++ stdcxx/trunk/include/rw/_meta_other.h Fri Aug 1 13:51:17 2008
@@ -31,30 +31,23 @@
#define _RWSTD_RW_META_OTHER_H_INCLUDED
#include <rw/_defs.h>
+
#include <rw/_meta_cat.h>
#include <rw/_meta_ref.h>
+#include <rw/_meta_prop.h>
#include <rw/_meta_ptr.h>
+#include <rw/_static_assert.h>
+
+#include <rw/_static_assert.h>
_RWSTD_NAMESPACE (__rw) {
-/**
- * Metaprogramming conditional primitive that provides a member typedef
- * _C_type that is _TypeT if _Select is true, otherwise is _TypeU.
- *
- * The primary template is used when _Select is true.
- */
template <bool _Select, class _TypeT, class _TypeU>
struct __rw_conditional
{
typedef _TypeT type;
};
-/**
- * Metaprogramming conditional primitive that provides a member typedef
- * type is _TypeT if _Select is true, otherwise is _TypeU.
- *
- * This specialization if used when _Select is false.
- */
template <class _TypeT, class _TypeU>
struct __rw_conditional<false, _TypeT, _TypeU>
{
@@ -64,155 +57,158 @@
#define _RWSTD_CONDITIONAL(C,T,U) _RW::__rw_conditional<C,T,U>::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<N> { \
- typedef _RWSTD_TT_ALIGNED_POD(N) _C_type; \
-}
+#ifndef _RWSTD_NO_ALIGN_TRAITS
-_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.
- *
- * @tparam _Size The size of the object to align.
- * @tparam _N The power of two value being tested.
- * @tparam _Done Termination condition for recursion. Do not use.
- */
+// 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 };
};
-/**
- * Helper for __rw_default_alignment. The member value will evaluate
- * to the nearest power of two that is less than or equal to _Size.
- * This specialization is used to terminate recursion. It is only used
- * when when _Done in the primary template evaluates is true.
- *
- * @tparam _Size The size of the object to align.
- * @tparam _N The power of two value being tested.
- */
+// Helper for __rw_default_alignment. The member value will evaluate
+// to the nearest power of two that is less than or equal to _Size.
+// This specialization is used to terminate recursion. It is only used
+// when when _Done in the primary template evaluates is true.
template <_RWSTD_SIZE_T _Size, _RWSTD_SIZE_T _N>
struct __rw_default_alignment_impl<_Size, _N, true>
{
enum { value = _N };
};
-/**
- * Helper for __rw_aligned_storage. The value member shall be the most
- * most stringent alignment requirement for any C++ object whose size
- * is no greater than _Size. This implementation will set value to be
- * the nearest power of two value that is less than or equal to _Size.
- *
- * @tparam _Size Size of the object to calculate the alignment for.
- */
+
+// Helper for __rw_aligned_storage. The value member shall be the most
+// most stringent alignment requirement for any C++ object whose size
+// is no greater than _Size. This implementation will set value to be
+// the nearest power of two value that is less than or equal to _Size.
template <_RWSTD_SIZE_T _Size>
struct __rw_default_alignment
{
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.
+template <_RWSTD_SIZE_T _Align>
+struct __rw_aligned_storage_impl;
+
+#define _RWSTD_ALIGNED_STORAGE_SPEC(N) \
+ template <> struct __rw_aligned_storage_impl<N> { \
+ 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
-/**
- * Helper for __rw_aligned_union. Provides a typedef type that
- * is the largest type in the sequence of provided types.
- */
+// Helper for __rw_aligned_union. Provides a typedef type that
+// is the largest type in the sequence of provided types.
template <class... _Types>
struct __rw_biggest;
template <class _TypeT, class... _Types>
struct __rw_biggest<_TypeT, _Types...>
{
- typedef typename
- __rw_biggest<_Types...>::type _TypeU;
-
- typedef typename
- __rw_conditional<sizeof (_TypeT) < sizeof (_TypeU),
- _TypeU, _TypeT>::type type;
+ enum { _C_values = __rw_biggest<_Types...>::_C_value,
+ _C_value = sizeof (_TypeT) < _C_values
+ ? _C_values
+ : sizeof (_TypeT) };
};
template <class _TypeT>
struct __rw_biggest<_TypeT>
{
- typedef _TypeT type;
+ enum { _C_value = sizeof (_TypeT) };
};
-/**
- * Helper for __rw_aligned_union. Provides a typedef type that
- * is the type with the strictest alignment requirement in the
- * sequence of provided types.
- */
+// Helper for __rw_aligned_union.
template <class... _Types>
struct __rw_strictest;
template <class _TypeT, class... _Types>
struct __rw_strictest<_TypeT, _Types...>
{
- typedef typename
- __rw_strictest<_Types...>::type _TypeU;
-
- typedef typename
- __rw_conditional< __rw_alignment_of<_TypeT>::value
- < __rw_alignment_of<_TypeU>::value,
- _TypeU, _TypeT>::type type;
+ enum { _C_values = __rw_strictest<_Types...>::_C_value,
+ _C_value = __rw_alignment_of<_TypeT>::value < _C_values
+ ? _C_values
+ : __rw_alignment_of<_TypeT>::value };
};
template <class _TypeT>
struct __rw_strictest<_TypeT>
{
- typedef _TypeT type;
+ enum { _C_value = __rw_alignment_of<_TypeT>::value };
};
template <_RWSTD_SIZE_T _Len, class... _Types>
@@ -221,125 +217,72 @@
template <_RWSTD_SIZE_T _Len, class _TypeT, class... _Types>
struct __rw_aligned_union<_Len, _TypeT, _Types...>
{
- typedef typename
- __rw_biggest<_TypeT, _Types...>::type _C_biggest;
+ enum { _C_len_value = _Len,
+ _C_size_value = __rw_biggest<_TypeT, _Types...>::_C_value,
+ _C_align_value = __rw_strictest<_TypeT, _Types...>::_C_value };
typedef typename
- __rw_strictest<_TypeT, _Types...>::type _C_strictest;
-
- static const _RWSTD_SIZE_T _C_size_value =
- sizeof (_C_biggest);
-
- static const _RWSTD_SIZE_T alignment_value =
- __rw_alignment_of<_C_strictest>::value;
-
- typedef typename
- __rw_aligned_storage<_Len < _C_size_value ? _C_size_value : _Len,
- alignment_value>::type type;
+ __rw_aligned_storage< _C_len_value < _C_size_value
+ ? _C_size_value : _C_len_value,
+ _C_align_value>::type type;
};
-#if 0
-# ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
-
-template <_RWSTD_SIZE_T _Len, class... _Types>
-const _RWSTD_SIZE_T
-__rw_aligned_union<_Len, _Types...>::alignment_value;
-
-template <_RWSTD_SIZE_T _Len, class... _Types>
-const _RWSTD_SIZE_T
-__rw_aligned_union<_Len, _Types...>::_C_size_value;
+#else // _RWSTD_NO_VARIADIC_TEMPLATES
-# endif // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
-#endif
+// Helper. Gives the largest of a series of values.
+template <unsigned _A , unsigned _B = 0,
+ unsigned _C = 0, unsigned _D = 0,
+ unsigned _E = 0, unsigned _F = 0,
+ unsigned _G = 0, unsigned _H = 0>
+struct __rw_max_uint
+{
+ enum {
+ _C_ab = _A < _B ? _B : _A,
+ _C_cd = _C < _D ? _D : _C,
+ _C_abcd = _C_ab < _C_cd ? _C_cd : _C_ab,
+
+ _C_ef = _E < _F ? _F : _E,
+ _C_gh = _G < _H ? _H : _G,
+ _C_efgh = _C_ef < _C_gh ? _C_gh : _C_ef,
-#else // _RWSTD_NO_VARIADIC_TEMPLATES
+ _C_value = _C_abcd < _C_efgh ? _C_efgh : _C_abcd
+ };
+};
struct __rw_empty { };
-/**
- * Helper for __rw_aligned_union. Provides a typedef type that
- * is the largest type in the sequence of provided types.
- */
+// Helper for __rw_aligned_union.
template <class _Type1 , class _Type2 = __rw_empty,
class _Type3 = __rw_empty, class _Type4 = __rw_empty,
class _Type5 = __rw_empty, class _Type6 = __rw_empty,
class _Type7 = __rw_empty, class _Type8 = __rw_empty>
struct __rw_biggest
{
- typedef typename
- __rw_conditional<(sizeof _Type1 < sizeof _Type2),
- _Type2, _Type1>::type _Type12;
-
- typedef typename
- __rw_conditional<(sizeof _Type3 < sizeof _Type4),
- _Type4, _Type3>::type _Type34;
-
- typedef typename
- __rw_conditional<(sizeof _Type5 < sizeof _Type6),
- _Type6, _Type5>::type _Type56;
-
- typedef typename
- __rw_conditional<(sizeof _Type7 < sizeof _Type8),
- _Type8, _Type7>::type _Type78;
-
- typedef typename
- __rw_conditional<(sizeof _Type12 < sizeof _Type34),
- _Type34, _Type12>::type _Type1234;
-
- typedef typename
- __rw_conditional<(sizeof _Type56 < sizeof _Type78),
- _Type78, _Type56>::type _Type5678;
-
- typedef typename
- __rw_conditional<(sizeof _Type1234 < sizeof _Type5678),
- _Type5678, _Type1234>::type type;
+ enum { _C_value =
+ __rw_max_uint<sizeof (_Type1), sizeof (_Type2),
+ sizeof (_Type3), sizeof (_Type4),
+ sizeof (_Type5), sizeof (_Type6),
+ sizeof (_Type7), sizeof (_Type8)>::_C_value
+ };
};
-/**
- * Helper for __rw_aligned_union. Provides a typedef type that
- * is the type with the strictest alignment requirement in the
- * sequence of provided types.
- */
+// Helper for __rw_aligned_union.
template <class _Type1 , class _Type2 = __rw_empty,
class _Type3 = __rw_empty, class _Type4 = __rw_empty,
class _Type5 = __rw_empty, class _Type6 = __rw_empty,
class _Type7 = __rw_empty, class _Type8 = __rw_empty>
struct __rw_strictest
{
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type1>::value)
- < (__rw_alignment_of<_Type2>::value),
- _Type2, _Type1>::type _Type12;
-
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type3>::value)
- < (__rw_alignment_of<_Type4>::value),
- _Type4, _Type3>::type _Type34;
-
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type5>::value)
- < (__rw_alignment_of<_Type6>::value),
- _Type6, _Type5>::type _Type56;
-
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type7>::value)
- < (__rw_alignment_of<_Type8>::value),
- _Type8, _Type7>::type _Type78;
-
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type12>::value)
- < (__rw_alignment_of<_Type34>::value),
- _Type34, _Type12>::type _Type1234;
-
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type56>::value)
- < (__rw_alignment_of<_Type78>::value),
- _Type78, _Type56>::type _Type5678;
-
- typedef typename
- __rw_conditional< (__rw_alignment_of<_Type1234>::value)
- < (__rw_alignment_of<_Type5678>::value),
- _Type5678, _Type1234>::type type;
+ enum { _C_value =
+ __rw_max_uint<__rw_alignment_of<_Type1>::value,
+ __rw_alignment_of<_Type2>::value,
+ __rw_alignment_of<_Type3>::value,
+ __rw_alignment_of<_Type4>::value,
+ __rw_alignment_of<_Type5>::value,
+ __rw_alignment_of<_Type6>::value,
+ __rw_alignment_of<_Type7>::value,
+ __rw_alignment_of<_Type8>::value>::_C_value
+ };
};
template <_RWSTD_SIZE_T _Len,
@@ -349,69 +292,32 @@
class _Type7 = __rw_empty, class _Type8 = __rw_empty>
struct __rw_aligned_union
{
- typedef typename
- __rw_biggest<_Type1, _Type2, _Type3, _Type4,
- _Type5, _Type6, _Type7, _Type8>::type _C_biggest;
-
- typedef typename
- __rw_strictest<_Type1, _Type2, _Type3, _Type4,
- _Type5, _Type6, _Type7, _Type8>::type _C_strictest;
-
- static const _RWSTD_SIZE_T _C_size_value =
- sizeof (_C_biggest);
-
- static const _RWSTD_SIZE_T alignment_value =
- __rw_alignment_of<_C_strictest>::value;
+ enum { _C_len_value = _Len,
+ _C_size_value =
+ __rw_biggest<_Type1, _Type2, _Type3, _Type4,
+ _Type5, _Type6, _Type7, _Type8>::_C_value,
+ _C_align_value =
+ __rw_strictest<_Type1, _Type2, _Type3, _Type4,
+ _Type5, _Type6, _Type7, _Type8>::_C_value
+ };
typedef typename
- __rw_aligned_storage<_C_size_value < _Len ? _Len : _C_size_value,
- alignment_value>::type type;
+ __rw_aligned_storage< _C_size_value < _C_len_value
+ ? _C_len_value : _C_size_value,
+ _C_align_value>::type type;
};
-#ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
-
-template <_RWSTD_SIZE_T _Len,
- class _Type1, class _Type2, class _Type3, class _Type4,
- class _Type5, class _Type6, class _Type7, class _Type8>
-const _RWSTD_SIZE_T
-__rw_aligned_union<_Len,
- _Type1, _Type2, _Type3, _Type4,
- _Type5, _Type6, _Type7, _Type8>::alignment_value;
-
-template <_RWSTD_SIZE_T _Len,
- class _Type1, class _Type2, class _Type3, class _Type4,
- class _Type5, class _Type6, class _Type7, class _Type8>
-const _RWSTD_SIZE_T
-__rw_aligned_union<_Len,
- _Type1, _Type2, _Type3, _Type4,
- _Type5, _Type6, _Type7, _Type8>::_C_size_value;
-
-#endif // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
-
#endif // !_RWSTD_NO_VARIADIC_TEMPLATES
+#endif // !_RWSTD_NO_ALIGN_TRAITS
-/**
- * Conditional primitive that provides a member typedef type that is
- * _TypeT if _Enable is true, otherwise there will be no such typedef.
- *
- * The primary template provides an implementation for the case that
- * _Enable is true.
- */
template <bool _Enable, class _TypeT = void>
struct __rw_enable_if
{
typedef _TypeT type;
};
-/**
- * Conditional primitive that provides a member typedef type that is
- * _TypeT if _Enable is true, otherwise there will be no such typedef.
- *
- * The specialization provides an implementation for the case that _Enable
- * is false.
- */
template <class _TypeT>
struct __rw_enable_if<false, _TypeT>
{
@@ -420,26 +326,12 @@
#define _RWSTD_ENABLE_IF(C,T) _RW::__rw_enable_if<C,T>::type
-/**
- * Conditional primitive that provides a member typedef type that is
- * _TypeT if _Enable is false, otherwise there will be no such typedef.
- *
- * The primary template provides an implementation for the case that
- * _Enable is false.
- */
template <bool _Enable, class _TypeT = void>
struct __rw_disable_if
{
typedef _TypeT type;
};
-/**
- * Conditional primitive that provides a member typedef type that is
- * _TypeT if _Enable is false, otherwise there will be no such typedef.
- *
- * The specialization provides an implementation for the case that _Enable
- * is false.
- */
template <class _TypeT>
struct __rw_disable_if<true, _TypeT>
{
@@ -448,17 +340,6 @@
#define _RWSTD_DISABLE_IF(C,T) _RW::__rw_disable_if<C,T>::type
-/**
- * TransformationTrait that implements compile time array-to-pointer
- * conversions and function-to-pointer conversions for the given type
- * _TypeT.
- *
- * Let _TypeU be __rw_remove_ref<_TypeT>::type. If _TypeT is an
- * array type, the member typedef type shall equal to the type of
- * __rw_remove_extent<_TypeU>::type*. If _TypeT is a function type,
- * the member typedef type shall be __rw_add_ptr<_TypeU>::type.
- * Otherwise type will be __rw_remove_cv<_TypeU>::type.
- */
template <class _TypeT>
struct __rw_decay
{
Modified: stdcxx/trunk/include/rw/_meta_prop.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_prop.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_prop.h (original)
+++ stdcxx/trunk/include/rw/_meta_prop.h Fri Aug 1 13:51:17 2008
@@ -32,9 +32,9 @@
#include <rw/_defs.h>
#include <rw/_meta_cat.h>
+#include <rw/_meta_comp.h>
#include <rw/_meta_arr.h>
#include <rw/_meta_cv.h>
-#include <rw/_static_assert.h>
_RWSTD_NAMESPACE (__rw) {
@@ -44,9 +44,6 @@
template <> struct Trait<Type volatile> : __rw_true_type { }; \
template <> struct Trait<Type const volatile> : __rw_true_type { }
-/**
- * UnaryTypeTrait indicates that _TypeT is const-qualified.
- */
template <class _TypeT>
struct __rw_is_const : __rw_false_type
{
@@ -57,9 +54,6 @@
{
};
-/**
- * UnaryTypeTrait indicates that _TypeT is volatile-qualified.
- */
template <class _TypeT>
struct __rw_is_volatile : __rw_false_type
{
@@ -70,294 +64,479 @@
{
};
+#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<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_standard_layout_impl
+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
+{
+};
+
+#endif
+
+#define _RWSTD_IS_CONST(T) _RW::__rw_is_const<T>::value
+#define _RWSTD_IS_VOLATILE(T) _RW::__rw_is_volatile<T>::value
+
+
+#if !defined(_RWSTD_TT_IS_POD)
+
+template <class _TypeT>
+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_cv<_TypeU>::type _NoCV_TypeU;
+
+ enum { _C_value = __rw_is_scalar<_NoCV_TypeU>::value };
};
+# define _RWSTD_IS_POD(T) _RW::__rw_is_pod_impl<T>::_C_value
+
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
+
template <class _TypeT>
struct __rw_is_pod_impl
{
typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU;
+ typedef typename __rw_remove_cv<_TypeU>::type _NoCV_TypeU;
- enum { _C_value = __rw_is_scalar<_TypeU>::value
-#ifdef _RWSTD_TT_IS_POD
- || _RWSTD_TT_IS_POD(_TypeU)
-#endif
- };
+ // __is_pod works for pod class types only, add scalars
+ enum { _C_value = __rw_is_scalar<_NoCV_TypeU>::value
+ || _RWSTD_TT_IS_POD(_NoCV_TypeU) };
};
+# define _RWSTD_IS_POD(T) _RW::__rw_is_pod_impl<T>::_C_value
+
+#else
+# define _RWSTD_IS_POD(T) _RWSTD_TT_IS_POD(T)
+#endif // _RWSTD_TT_IS_POD
+
template <class _TypeT>
-struct __rw_is_empty_impl
+struct __rw_is_pod
+ : __rw_integral_constant<bool, _RWSTD_IS_POD(_TypeT)>
{
- 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<T>::_C_value
-#ifdef _MSC_VER
+#if !defined (_RWSTD_TT_IS_STANDARD_LAYOUT)
+# define _RWSTD_IS_STANDARD_LAYOUT(T) _RWSTD_IS_POD(T)
+#else
+# define _RWSTD_IS_STANDARD_LAYOUT(T) _RWSTD_TT_IS_STANDARD_LAYOUT(T)
+#endif // _RWSTD_TT_IS_STANDARD_LAYOUT
-# undef _RWSTD_TT_IS_POD
-# define _RWSTD_TT_IS_POD(T) __rw_is_pod_impl<T>::_C_value
+template <class _TypeT>
+struct __rw_is_standard_layout
+ : __rw_integral_constant<bool, _RWSTD_IS_STANDARD_LAYOUT(_TypeT)>
+{
+};
-# undef _RWSTD_TT_IS_EMPTY
-# define _RWSTD_TT_IS_EMPTY(T) __rw_is_empty_impl<T>::_C_value
-#endif // _MSC_VER
+#if defined (_RWSTD_TT_IS_EMPTY)
+# 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
-/**
- * UnaryTypeTrait indicates that _TypeT is a standard layout type.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified)
- */
-template <class _TypeT>
-struct __rw_is_standard_layout
- : __rw_integral_constant<bool, _RWSTD_TT_IS_STDANDARD_LAYOUT(_TypeT)>
+#elif defined (_RWSTD_TT_IS_CLASS) || defined (_RWSTD_TT_IS_UNION)
+
+//
+// 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 <class _TypeT, bool = __rw_is_class<_TypeT>::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) };
};
-/**
- * UnaryTypeTrait indicates that _TypeT is a pod type.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified)
- */
+//
+// This specialization is for the case that _TypeT is a union or other
+// non-class type.
+//
template <class _TypeT>
-struct __rw_is_pod
- : __rw_integral_constant<bool, _RWSTD_TT_IS_POD(_TypeT)>
+struct __rw_is_empty_impl<_TypeT, false>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
+ enum { _C_value = 0 };
};
-/**
- * UnaryTypeTrait indicates that _TypeT is an empty type.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+# define _RWSTD_IS_EMPTY(T) _RW::__rw_is_empty_impl<T>::_C_value
+
+#else
+ // 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
+
template <class _TypeT>
struct __rw_is_empty
- : __rw_integral_constant<bool, _RWSTD_TT_IS_EMPTY(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_IS_EMPTY(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT is a polymorphic type.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+#if defined (_RWSTD_TT_IS_POLYMORPHIC)
+# define _RWSTD_IS_POLYMORPHIC(T) _RWSTD_TT_IS_POLYMORPHIC(T)
+#elif defined (_RWSTD_TT_IS_CLASS) || defined (_RWSTD_TT_IS_UNION)
+
+//
+// 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 <class _TypeT, bool = __rw_is_class<_TypeT>::value>
+struct __rw_is_polymorphic_impl
+{
+ template <class _TypeU>
+ struct _C_type_1 : _TypeU
+ {
+ // only polymorphic if _TypeT is
+ };
+
+ template <class _TypeU>
+ 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 <class _TypeT>
+struct __rw_is_polymorphic_impl<_TypeT, false>
+{
+ enum { _C_value = 0 };
+};
+
+# define _RWSTD_IS_POLYMORPHIC(T) \
+ _RW::__rw_is_polymorphic_impl<T>::_C_value
+
+#else
+# define _RWSTD_IS_POLYMORPHIC(T) _RW::__rw_is_class_or_union<T>::value
+#endif // _RWSTD_TT_IS_POLYMORPHIC
+
template <class _TypeT>
struct __rw_is_polymorphic
- : __rw_integral_constant<bool, _RWSTD_TT_IS_POLYMORPHIC(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_IS_POLYMORPHIC(_TypeT)>
+{
+};
+
+
+
+#if defined (_RWSTD_TT_IS_ABSTRACT)
+# define _RWSTD_IS_ABSTRACT(T) _RWSTD_TT_IS_ABSTRACT(T)
+#elif defined (_RWSTD_TT_IS_CLASS) || defined (_RWSTD_TT_IS_UNION)
+
+//
+// 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 <class _TypeT, bool = __rw_is_class<_TypeT>::value>
+struct __rw_is_abstract_impl
+{
+ struct _C_no { };
+ struct _C_yes { _C_no __pad[2]; };
+
+ template <class U>
+ static _C_yes _C_is (int, ...);
+
+ template <class U>
+ 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 <class T>
+struct __rw_is_abstract_impl<T,true>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
+ enum { _C_value = 0 };
};
-/**
- * UnaryTypeTrait indicates that _TypeT is an abstract type.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+# define _RWSTD_IS_ABSTRACT(T) _RW::__rw_is_abstract_impl<T>::_C_value
+
+#else
+# define _RWSTD_IS_ABSTRACT(T) _RW::__rw_is_class_or_union<T>::value
+#endif // !_RWSTD_TT_IS_ABSTRACT
+
template <class _TypeT>
struct __rw_is_abstract
- : __rw_integral_constant<bool, _RWSTD_TT_IS_ABSTRACT(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_IS_ABSTRACT(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a trivial default constructor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+
+#if !defined (_RWSTD_TT_HAS_TRIVIAL_CTOR)
+# define _RWSTD_HAS_TRIVIAL_CTOR(T) _RW::__rw_is_pod<T>::value
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
+
+template <class _TypeT>
+struct __rw_has_trivial_ctor_impl
+{
+ typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU;
+
+ enum { _C_value = __rw_is_scalar<_TypeU>::value
+ || _RWSTD_TT_HAS_TRIVIAL_CTOR (_TypeU) };
+};
+
+# define _RWSTD_HAS_TRIVIAL_CTOR(T) \
+ _RW::__rw_has_trivial_ctor_impl<T>::_C_value
+
+#else
+# define _RWSTD_HAS_TRIVIAL_CTOR(T) _RWSTD_TT_HAS_TRIVIAL_CTOR(T)
+#endif // _RWSTD_TT_HAS_TRIVIAL_CTOR
+
template <class _TypeT>
struct __rw_has_trivial_ctor
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_TRIVIAL_CTOR(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_TRIVIAL_CTOR(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a trivial copy constructor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+
+#if !defined (_RWSTD_TT_HAS_TRIVIAL_COPY)
+# define _RWSTD_HAS_TRIVIAL_COPY(T) \
+ ( !_RW::__rw_is_array<T>::value \
+ && ( _RW::__rw_is_reference<T>::value \
+ || _RW::__rw_is_pod<T>::value))
+#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 \
+ || _RWSTD_TT_HAS_TRIVIAL_COPY(T))
+#elif defined (__GNUG__)
+# define _RWSTD_HAS_TRIVIAL_COPY(T) \
+ (!_RW::__rw_is_array<T>::value && _RWSTD_TT_HAS_TRIVIAL_COPY(T))
+#else
+# define _RWSTD_HAS_TRIVIAL_COPY(T) _RWSTD_TT_HAS_TRIVIAL_COPY(T)
+#endif // !_RWSTD_TT_HAS_TRIVIAL_COPY
+
template <class _TypeT>
struct __rw_has_trivial_copy
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_TRIVIAL_COPY(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_TRIVIAL_COPY(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a trivial assignment operator.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+#if !defined (_RWSTD_TT_HAS_TRIVIAL_ASSIGN)
+# define _RWSTD_HAS_TRIVIAL_ASSIGN(T) \
+ ( _RW::__rw_is_pod<T>::value \
+ && !_RW::__rw_is_const<T>::value \
+ && !_RW::__rw_is_reference<T>::value \
+ && !_RW::__rw_is_array<T>::value)
+#elif defined (__EDG_VERSION__)
+# define _RWSTD_HAS_TRIVIAL_ASSIGN(T) \
+ (!_RW::__rw_is_array<T>::value \
+ && !_RW::__rw_is_const<T>::value \
+ && !_RW::__rw_is_reference<T>::value \
+ && (_RW::__rw_is_scalar<T>::value || _RWSTD_TT_HAS_TRIVIAL_ASSIGN(T)))
+#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
+
template <class _TypeT>
struct __rw_has_trivial_assign
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_TRIVIAL_ASSIGN(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_TRIVIAL_ASSIGN(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a trivial destructor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+
+#if !defined (_RWSTD_TT_HAS_TRIVIAL_DTOR)
+# define _RWSTD_HAS_TRIVIAL_DTOR(T) \
+ (_RW::__rw_is_pod<T>::value || _RW::__rw_is_reference<T>::value)
+#elif defined (__GNUC__)
+# define _RWSTD_HAS_TRIVIAL_DTOR(T) \
+ ( _RW::__rw_is_reference<_TypeT>::value \
+ || _RWSTD_TT_HAS_TRIVIAL_DTOR (_TypeT))
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
+
+template <class _TypeT>
+struct __rw_has_trivial_dtor_impl
+{
+ typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU;
+
+ enum { _C_value = __rw_is_scalar<_TypeU>::value
+ || __rw_is_reference<_TypeU>::value
+ || _RWSTD_TT_HAS_TRIVIAL_DTOR (_TypeU) };
+};
+
+# define _RWSTD_HAS_TRIVIAL_DTOR(T) \
+ _RW::__rw_has_trivial_dtor_impl<T>::_C_value
+
+#else
+# define _RWSTD_HAS_TRIVIAL_DTOR(T) _RWSTD_TT_HAS_TRIVIAL_DTOR(T)
+#endif // !_RWSTD_TT_HAS_TRIVIAL_DTOR
+
template <class _TypeT>
struct __rw_has_trivial_dtor
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_TRIVIAL_DTOR(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_TRIVIAL_DTOR(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT is a trivial type or
- * an array of trivial type.
- */
+
+
template <class _TypeT>
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_all_extents<_TypeT>::type _TypeU;
+ typedef typename __rw_remove_cv<_TypeU>::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) };
+};
- 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) };
-};
-
-/**
- * UnaryTypeTrait indicates that _TypeT is a trivial type or an array of
- * trivial type.
- *
- * Trivial types include scalar types, and trivial class types. A trivial
- * class type has a trivial default ctor, copy ctor, operator= and dtor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
template <class _TypeT>
struct __rw_is_trivial
: __rw_integral_constant<bool, __rw_is_trivial_impl<_TypeT>::_C_value>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait to determine if _TypeT has a nothrow default constructor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+#define _RWSTD_IS_TRIVIAL(T) _RW::__rw_is_trivial<T>::value
+
+
+
+#if !defined (_RWSTD_TT_HAS_NOTHROW_CTOR)
+# define _RWSTD_HAS_NOTHROW_CTOR(T) _RW::__rw_has_trivial_ctor<T>::value
+#elif defined (__EDG_VERSION__) || defined (_MSC_VER)
+
+template <class _TypeT>
+struct __rw_has_nothrow_ctor_impl
+{
+ typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU;
+
+ enum { _C_value = __rw_has_trivial_ctor<_TypeT>::value
+ || _RWSTD_TT_HAS_NOTHROW_CTOR (_TypeU) };
+};
+
+# define _RWSTD_HAS_NOTHROW_CTOR(T) \
+ _RW::__rw_has_nothrow_ctor_impl<T>::_C_value
+
+#else
+# define _RWSTD_HAS_NOTHROW_CTOR(T) _RWSTD_TT_HAS_NOTHROW_CTOR(T)
+#endif // _RWSTD_TT_HAS_NOTHROW_CTOR
+
template <class _TypeT>
struct __rw_has_nothrow_ctor
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_NOTHROW_CTOR(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_NOTHROW_CTOR(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a nothrow copy constructor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+#if !defined (_RWSTD_TT_HAS_NOTHROW_COPY)
+# define _RWSTD_HAS_NOTHROW_COPY(T) _RW::__rw_has_trivial_copy<T>::value
+#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__)
+# define _RWSTD_HAS_NOTHROW_COPY(T) \
+ (!_RW::__rw_is_array<T>::value && _RWSTD_TT_HAS_NOTHROW_COPY(T))
+#else
+# define _RWSTD_HAS_NOTHROW_COPY(T) _RWSTD_TT_HAS_NOTHROW_COPY(T)
+#endif // !_RWSTD_TT_HAS_NOTHROW_COPY
+
template <class _TypeT>
struct __rw_has_nothrow_copy
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_NOTHROW_COPY(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_NOTHROW_COPY(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a nothrow assignment operator.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+
+#if !defined (_RWSTD_TT_HAS_NOTHROW_ASSIGN)
+# 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)))
+#elif defined (__GNUG__)
+# define _RWSTD_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
+
template <class _TypeT>
struct __rw_has_nothrow_assign
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_NOTHROW_ASSIGN(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_NOTHROW_ASSIGN(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait indicates that _TypeT has a virtual destructor.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+
+#if !defined (_RWSTD_TT_HAS_VIRTUAL_DTOR)
+# define _RWSTD_HAS_VIRTUAL_DTOR(T) _RW::__rw_is_polymorphic<T>::value
+#else
+# define _RWSTD_HAS_VIRTUAL_DTOR(T) _RWSTD_TT_HAS_VIRTUAL_DTOR(T)
+#endif // _RWSTD_TT_HAS_VIRTUAL_DTOR
+
template <class _TypeT>
struct __rw_has_virtual_dtor
- : __rw_integral_constant<bool, _RWSTD_TT_HAS_VIRTUAL_DTOR(_TypeT)>
+ : __rw_integral_constant<bool, _RWSTD_HAS_VIRTUAL_DTOR(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait that indicates that _TypeT is an unsigned type.
- */
+
template <class _TypeT>
struct __rw_is_unsigned : __rw_false_type
{
};
-/**
- * UnaryTypeTrait that indicates that _TypeT is a signed type.
- */
template <class _TypeT>
struct __rw_is_signed : __rw_false_type
{
@@ -394,62 +573,106 @@
_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
-/**
- * UnaryTypeTrait that gets the alignment of _TypeT.
- */
+#define _RWSTD_IS_SIGNED(T) _RW::__rw_is_signed<T>::value
+#define _RWSTD_IS_UNSIGNED(T) _RW::__rw_is_unsigned<T>::value
+
+
+
+#ifndef _RWSTD_NO_ALIGN_TRAITS
+
+# if defined (_RWSTD_TT_ALIGN_OF)
+# define _RWSTD_ALIGN_OF(T) _RWSTD_TT_ALIGN_OF(T)
+# else
+
+template <class _TypeT>
+struct __rw_alignment_of_impl
+{
+ template <class _TypeU>
+ struct _C_nest
+ {
+ unsigned char _C_char;
+ _TypeU _C_type;
+ };
+
+ enum { _C_value =
+ sizeof (_C_nest<_TypeT>) - sizeof (_TypeT) < sizeof (_TypeT)
+ ? sizeof (_C_nest<_TypeT>) - sizeof (_TypeT) < sizeof (_TypeT)
+ : sizeof (_TypeT) };
+};
+
+template <>
+struct __rw_alignment_of_impl<void>
+{
+ enum { _C_value = 0 };
+};
+
+template <>
+struct __rw_alignment_of_impl<const void>
+{
+ enum { _C_value = 0 };
+};
+
+template <>
+struct __rw_alignment_of_impl<volatile void>
+{
+ enum { _C_value = 0 };
+};
+
+template <>
+struct __rw_alignment_of_impl<const volatile void>
+{
+ enum { _C_value = 0 };
+};
+
+# define _RWSTD_ALIGN_OF(T) _RW::__rw_alignment_of_impl<T>::_C_value
+# endif // !_RWSTD_TT_ALIGN_OF
+
template <class _TypeT>
struct __rw_alignment_of
- : __rw_integral_constant<_RWSTD_SIZE_T, _RWSTD_TT_ALIGN_OF(_TypeT)>
+ : __rw_integral_constant<_RWSTD_SIZE_T, _RWSTD_ALIGN_OF(_TypeT)>
{
- //_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
- // || _RWSTD_IS_ARRAY (_TypeT)
- // || _RWSTD_IS_VOID (_TypeT));
};
-/**
- * UnaryTypeTrait gives the number of dimensions of the type _TypeT, if
- * _TypeT is an array, otherwise 0. The primary template is for non-array
- * types.
- */
+#endif // !_RWSTD_NO_ALIGN_TRAITS
+
template <class _TypeT>
struct __rw_rank
: __rw_integral_constant<_RWSTD_SIZE_T, 0>
{
};
-/**
- * UnaryTypeTrait gives the number of dimensions of the type _TypeT, if
- * _TypeT is an array, otherwise 0. The primary template is for bounded
- * -array types.
- */
template <class _TypeT, _RWSTD_SIZE_T _Size>
struct __rw_rank<_TypeT [_Size]>
: __rw_integral_constant<_RWSTD_SIZE_T, 1 + __rw_rank<_TypeT>::value>
{
};
-/**
- * UnaryTypeTrait gives the number of dimensions of the type _TypeT, if
- * _TypeT is an array, otherwise 0. The primary template is for unbounded
- * -array types.
- */
+#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
+
template <class _TypeT>
struct __rw_rank<_TypeT []>
: __rw_integral_constant<_RWSTD_SIZE_T, 1 + __rw_rank<_TypeT>::value>
{
};
+#endif
+
+#define _RWSTD_RANK(T) _RW::__rw_rank<T>::value
+
+
-/**
- * UnaryTypeTrait gives the size of the _Depth dimension of _TypeT.
- */
template <class _TypeT, _RWSTD_SIZE_T _Depth>
struct __rw_extent
: __rw_integral_constant<_RWSTD_SIZE_T, 0>
@@ -458,28 +681,40 @@
template <class _TypeT, _RWSTD_SIZE_T _Size, _RWSTD_SIZE_T _Depth>
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>
{
};
+#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
+
template <class _TypeT, _RWSTD_SIZE_T _Depth>
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>
{
};
+#endif
+
template <class _TypeT, _RWSTD_SIZE_T _Size>
struct __rw_extent<_TypeT [_Size], 0>
: __rw_integral_constant<_RWSTD_SIZE_T, _Size>
{
};
+#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
+
template <class _TypeT>
struct __rw_extent<_TypeT [], 0>
: __rw_integral_constant<_RWSTD_SIZE_T, 0>
{
};
+#endif
+
+#define _RWSTD_EXTENT(T,D) _RW::__rw_extent<T,D>::value
+
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_ptr.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_ptr.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_ptr.h (original)
+++ stdcxx/trunk/include/rw/_meta_ptr.h Fri Aug 1 13:51:17 2008
@@ -35,32 +35,20 @@
_RWSTD_NAMESPACE (__rw) {
-/**
- * TransformationTrait strips a single level of pointer indirection from
- * _TypeT. The primary template is for non-pointer types.
- */
template <class _TypeT>
struct __rw_remove_pointer
{
typedef _TypeT type;
};
-/**
- * TransformationTrait adds a single level of pointer indirection to
- * _TypeT. This specialization is for pointer types.
- */
template <class _TypeT>
struct __rw_remove_pointer<_TypeT*>
{
typedef _TypeT type;
};
-//#define _RWSTD_REMOVE_POINTER(T) typename _RW::__rw_remove_pointer<T>::type
+#define _RWSTD_REMOVE_POINTER(T) _RW::__rw_remove_pointer<T>::type
-/**
- * TransformationTrait adds a single level of pointer indirection to
- * _TypeT.
- */
template <class _TypeT>
struct __rw_add_pointer
{
@@ -68,7 +56,7 @@
__rw_remove_reference<_TypeT>::type* type;
};
-//#define _RWSTD_ADD_POINTER(T) typename _RW::__rw_add_pointer<T>::type
+#define _RWSTD_ADD_POINTER(T) _RW::__rw_add_pointer<T>::type
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_ref.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_ref.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_ref.h (original)
+++ stdcxx/trunk/include/rw/_meta_ref.h Fri Aug 1 13:51:17 2008
@@ -36,24 +36,12 @@
_RWSTD_NAMESPACE (__rw) {
-/**
- * TransformationTrait strips any top level reference specifier
- * from _TypeT.
- *
- * The primary template is for non-reference types.
- */
template <class _TypeT>
struct __rw_remove_reference
{
typedef _TypeT type;
};
-/**
- * TransformationTrait strips any top level reference specifier
- * from _TypeT.
- *
- * This specialization is for lvalue reference types.
- */
template <class _TypeT>
struct __rw_remove_reference<_TypeT&>
{
@@ -62,12 +50,6 @@
#ifndef _RWSTD_NO_RVALUE_REFERENCES
-/**
- * TransformationTrait strips any top level reference specifier
- * from _TypeT.
- *
- * This specialization is for rval reference types.
- */
template <class _TypeT>
struct __rw_remove_reference<_TypeT&&>
{
@@ -76,6 +58,9 @@
#endif // _RWSTD_NO_RVALUE_REFERENCES
+#define _RWSTD_REMOVE_REFERENCE(T) _RW::__rw_remove_reference<T>::type
+
+
template <class _TypeT, bool = !__rw_is_void<_TypeT>::value
&& !__rw_is_reference<_TypeT>::value,
bool = __rw_is_rvalue_reference<_TypeT>::value>
@@ -98,19 +83,19 @@
{
// 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;
};
-/**
- * TransformationTrait adds a lvalue reference to the input type _TypeT.
- */
template <class _TypeT>
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<T>::type
+
template <class _TypeT, bool = __rw_is_object<_TypeT>::value
|| __rw_is_function<_TypeT>::_C_type>
@@ -137,10 +122,12 @@
template <class _TypeT>
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<T>::type
} // namespace __rw
Modified: stdcxx/trunk/include/rw/_meta_rel.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_meta_rel.h?rev=681820&r1=681819&r2=681820&view=diff
==============================================================================
--- stdcxx/trunk/include/rw/_meta_rel.h (original)
+++ stdcxx/trunk/include/rw/_meta_rel.h Fri Aug 1 13:51:17 2008
@@ -32,87 +32,140 @@
#include <rw/_defs.h>
-#include <rw/_meta_arr.h>
-#include <rw/_meta_ptr.h>
-#include <rw/_meta_ref.h>
-#include <rw/_meta_cat.h>
-#include <rw/_meta_cv.h>
+#ifndef _RWSTD_TT_IS_CONVERTIBLE
+# include <rw/_meta_arr.h>
+# include <rw/_meta_ptr.h>
+# include <rw/_meta_ref.h>
+# include <rw/_meta_cat.h>
+# include <rw/_meta_cv.h>
+#endif // _RWSTD_TT_IS_CONVERTIBLE
+
+#ifndef _RWSTD_TT_IS_BASE_OF
+# include <rw/_meta_cv.h>
+# include <rw/_meta_ptr.h>
+#endif //_RWSTD_TT_IS_BASE_OF
_RWSTD_NAMESPACE (__rw) {
-/**
- * UnaryTypeTrait indicates that the given types _TypeT and _TypeU are
- * the same type, including cv-qualifiers.
- *
- * The primary template is for the case that _TypeT and _TypeU are indeed
- * different types.
- */
template <class _TypeT, class _TypeU>
struct __rw_is_same : __rw_false_type
{
};
-/**
- * UnaryTypeTrait indicates that the given types _TypeT and _TypeU are
- * the same type, including cv-qualifiers.
- *
- * This specialization is for the case that _TypeT and _TypeU are exactly
- * the same types.
- */
template <class _TypeT>
struct __rw_is_same<_TypeT, _TypeT> : __rw_true_type
{
};
-#define _RWSTD_IS_SAME(T,U) \
- __rw_is_same<T,U>::value
+#define _RWSTD_IS_SAME(T,U) _RW::__rw_is_same<T,U>::value
-/**
- * BinaryTypeTrait indicates that _TypeT is a base class of _TypeU
- * or _TypeT and _TypeU are not unions and name the same class type,
- * without regard to cv-qualifiers.
- *
- * If _TypeT and _TypeU are class types and are different types, without
- * regard to cv-qualifiers, then _TypeT shall be a complete type.
- */
-template <class _TypeT, class _TypeU>
-struct __rw_is_base_of
- : __rw_integral_constant<bool, _RWSTD_TT_IS_BASE_OF(_TypeT,_TypeU)>
-{
- //_RWSTD_ASSERT ( _RWSTD_IS_CLASS (_TypeT)
- // && _RWSTD_IS_CLASS (_TypeU)
- // && !_RWSTD_IS_SAME(_TypeT, _TypeU)
- // ||
-};
-#define _RWSTD_IS_BASE_OF(T,U) \
- __rw_is_base_of<T,U>::value
+#ifndef _RWSTD_TT_IS_BASE_OF
+//
+// Primary template handles case that either of _Base or _Derived
+// is not a class type.
+//
+template <class _Base, class _Derived,
+ bool = __rw_is_class<_Base>::value
+ && __rw_is_class<_Derived>::value>
+struct __rw_is_base_of_impl
+{
+ enum { _C_value = 0 };
+};
-/**
- * Primitive type trait tells us if we can create a _TypeU from a _TypeT.
- */
-template <class _TypeT, class _TypeU>
-struct __rw_is_convertible_impl
+//
+// This specialization is for the case that _Base and
+// _Derived are class types, but not the same type.
+//
+// This little gem was taken from a comp.lang.c++.moderated post
+// by Rani Sharoni [see http://tinyurl.com/6pdv3k]
+//
+template <class _Base, class _Derived>
+struct __rw_is_base_of_impl<_Base, _Derived, true>
{
struct _C_no { };
struct _C_yes { _C_no __pad [2]; };
- static _C_yes _C_is (int, _TypeU);
- static _C_no _C_is (int, ...);
+ struct _C_nest
+ {
+ operator const volatile _Base& () const;
+ operator const volatile _Derived& ();
+
+ // the template is used so that the compiler will prefer the
+ // non-template _C_is, in case that the conversion would be
+ // ambiguous (as it is in the case where the types are unrelated).
+ template <class _TypeT>
+ static _C_yes _C_is (const volatile _Derived&, _TypeT);
+ static _C_no _C_is (const volatile _Base& , int);
+ };
+
+ enum { _C_value =
+ _RW::__rw_is_same<const volatile _Base,
+ const volatile _Derived&>::value
+ || sizeof (_C_yes) == sizeof (_C_nest::_C_is (_C_nest (), 0))
+ };
+};
+
+//
+// This specialization is for the case that _Base and
+// _Derived are the same class type.
+//
+template <class _TypeT>
+struct __rw_is_base_of_impl<_TypeT, _TypeT, true>
+{
+ enum { _C_value = 1 };
+};
- static _TypeT _C_make ();
+# define _RWSTD_IS_BASE_OF(T,U) \
+ _RW::__rw_is_base_of_impl<T,U>::_C_value
- enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (0, _C_make ())) };
+#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
+
+template <class _Base, class _Derived>
+struct __rw_is_base_of
+ : __rw_integral_constant<bool, _RWSTD_IS_BASE_OF(_Base,_Derived)>
+{
+ //_RWSTD_ASSERT ( _RWSTD_IS_CLASS (_Base)
+ // && _RWSTD_IS_CLASS (_Derived)
+ // && !_RWSTD_IS_SAME(_Base, _Derived)
+ // ||
};
+#if !defined (_RWSTD_TT_IS_CONVERTIBLE)
+template <class _From, class _To>
+struct __rw_is_convertible_impl
+{
+ struct _C_no { };
+ struct _C_yes { _C_no __pad [2]; };
+
+ struct _Dummy
+ {
+ template <class _Anything>
+ _Dummy (_Anything);
+ };
+ template <class _TypeT>
+ static _C_no _C_is (_Dummy, _TypeT);
+ static _C_yes _C_is (_To, int);
+ static _From _C_make ();
-template <class _TypeT, class _TypeU, bool = __rw_is_array<_TypeT>::value,
- bool = __rw_is_function<_TypeT>::value>
+ enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (_C_make (), 0)) };
+};
+
+template <class _TypeT, class _TypeU,
+ bool = __rw_is_array<_TypeT>::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
@@ -121,28 +174,31 @@
};
template <class _TypeT, class _TypeU>
-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 <class _TypeT, class _TypeU>
-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 <class _TypeT, class _TypeU, bool = __rw_is_array<_TypeU>::value
- ||__rw_is_function<_TypeU>::value>
+template <class _TypeT, class _TypeU,
+ bool = __rw_is_array<_TypeU>::value
+ || __rw_is_function<_TypeU>::value>
struct __rw_is_convertible_2
{
// _TypeU is neither an array nor a function type
@@ -179,30 +235,35 @@
enum { _C_value = 1 };
};
-/**
- * BinaryTypeTrait indicates that _TypeT is convertible to _TypeU
- * using only implicit conversions.
- *
- * _TypeT shall be a complete type, an array of unknown bound, or void
- * (possibly cv-qualified).
- */
+# define _RWSTD_IS_CONVERTIBLE(T,U) \
+ _RW::__rw_is_convertible_1<T,U>::_C_value
+
+#elif defined (_MSC_VER)
+
template <class _TypeT, class _TypeU>
-struct __rw_is_convertible
-#ifdef _RWSTD_TT_IS_CONVERTIBLE
- : __rw_integral_constant<bool, _RWSTD_TT_IS_CONVERTIBLE(_TypeT,_TypeU)>
+struct __rw_is_convertible_1
+{
+ enum { _C_value =
+ __rw_is_void<_TypeT>::value && __rw_is_void<_TypeU>::value
+ || _RWSTD_TT_IS_CONVERTIBLE(_TypeT, _TypeU) };
+};
+
+# define _RWSTD_IS_CONVERTIBLE(T,U) \
+ _RW::__rw_is_convertible_1<T,U>::_C_value
+
#else
- : __rw_integral_constant<bool,
- __rw_is_convertible_1<_TypeT, _TypeU>::_C_value>
-#endif
+# define _RWSTD_IS_CONVERTIBLE(T,U) _RWSTD_TT_IS_CONVERTIBLE(T,U)
+#endif // _RWSTD_TT_IS_CONVERTIBLE
+
+template <class _TypeT, class _TypeU>
+struct __rw_is_convertible
+ : __rw_integral_constant<bool, _RWSTD_IS_CONVERTIBLE(_TypeT,_TypeU)>
{
//_RWSTD_COMPILE_ASSERT ( _RWSTD_IS_COMPLETE (_TypeT)
// || _RWSTD_IS_ARRAY (_TypeT)
// || _RWSTD_IS_VOID (_TypeT));
};
-#define _RWSTD_IS_CONVERTIBLE(T,U) \
- __rw_is_convertible<T,U>::value
-
} // namespace __rw