Thread: [complement-svn] SF.net SVN: complement: [1662] trunk/complement/explore/include/misc/ type_traits.
Status: Pre-Alpha
Brought to you by:
complement
[complement-svn] SF.net SVN: complement: [1662]
trunk/complement/explore/include/misc/ type_traits.h
From: <com...@us...> - 2007-08-03 10:09:14
|
Revision: 1662 http://complement.svn.sourceforge.net/complement/?rev=1662&view=rev Author: complement Date: 2007-08-03 03:09:12 -0700 (Fri, 03 Aug 2007) Log Message: ----------- more TR1 type traits Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-03 06:33:49 UTC (rev 1661) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-03 10:09:12 UTC (rev 1662) @@ -63,6 +63,18 @@ __SPEC_1(C,volatile T,B); \ __SPEC_1(C,const volatile T,B) +#define __SPEC_2(C,T,B) \ +template <class _Tp1, class _Tp2> \ +struct C<T> : \ + public integral_constant<bool, B> \ +{ } + +#define __SPEC_FULL2(C,T,B) \ +__SPEC_2(C,T,B); \ +__SPEC_2(C,const T,B); \ +__SPEC_2(C,volatile T,B); \ +__SPEC_2(C,const volatile T,B) + template <class _Tp> struct is_void : public false_type @@ -100,11 +112,35 @@ template <class _Tp> struct is_arithmetic : - public integral_constant<bool, (is_integral<_Tp>::value - || is_floating_point<_Tp>::value)> + public integral_constant<bool, (is_integral<_Tp>::value || is_floating_point<_Tp>::value)> { }; template <class _Tp> +struct is_fundamental : + public integral_constant<bool, (is_arithmetic<_Tp>::value || is_void<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_compound : + public integral_constant<bool, !is_fundamental<_Tp>::value> +{ }; + +template <class _Tp> +struct is_array : + public false_type +{ }; + +template <class _Tp, std::size_t _Sz> +struct is_array<_Tp[_Sz]> : + public true_type +{ }; + +template <class _Tp> +struct is_array<_Tp[]> : + public true_type +{ }; + +template <class _Tp> struct is_pointer : public false_type { }; @@ -112,11 +148,65 @@ __SPEC_FULL1(is_pointer,_Tp *,true); template <class _Tp> +struct is_reference : + public false_type +{ }; + +template <class _Tp> +struct is_reference<_Tp&> : + public true_type +{ }; + +template <class _Tp> +struct is_function : + public integral_constant<bool, !(/* __in_array<_Tp>::__value + || __is_union_or_class<_Tp>::value + || */ is_reference<_Tp>::value + || is_void<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_member_object_pointer : + public false_type +{ }; + +_SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); + +template <class _Tp> +struct is_member_function_pointer : + public false_type +{ }; + +_SPEC_FULL2(is_member_function_pointer, _Tp1 _Tp2::*,is_function<_Tp1>::value); + +template <class _Tp> +struct is_member_pointer : + public integral_constant<bool, (is_member_object_pointer<_Tp>::value || is_member_function_pointer<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_enum : + public integral_constant<bool, !(is_fundamental<_Tp>::value + || is_array<_Tp>::value + || is_pointer<_Tp>::value + || is_reference<_Tp>::value + || is_member_pointer<_Tp>::value + || is_function<_Tp>::value + /* || __is_union_or_class<_Tp>::value */) > +{ }; + +template <class _Tp> +struct is_object : + public integral_constant<bool, !(is_function<_Tp>::value /* || is_reference<_Tp>::value + || is_void<_Tp>::value */ )> +{ }; + +template <class _Tp> struct is_scalar : public integral_constant<bool, (is_arithmetic<_Tp>::value - /* || is_enum<_Tp>::value */ + || is_enum<_Tp>::value || is_pointer<_Tp>::value - /* || is_member_pointer<_Tp>::value */ )> + || is_member_pointer<_Tp>::value)> { }; template <class _Tp> @@ -138,15 +228,99 @@ }; template <class _Tp> +struct is_const : + public false_type +{ }; + +template <class _Tp> +struct is_const<_Tp const> : + public true_type +{ }; + +template <class _Tp> +struct is_volatile : + public false_type +{ }; + +template <class _Tp> +struct is_volatile<_Tp volatile> : + public true_type +{ }; + +template <class _Tp> struct is_pod : public integral_constant<bool, (is_void<_Tp>::value || is_scalar<typename remove_all_extents<_Tp>::type>::value)> { }; +template <class _Tp> +struct has_trivial_constructor : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_trivial_copy : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_trivial_assign : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_trivial_destructor : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_nothrow_constructor : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_nothrow_copy : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_nothrow_assign : + public integral_constant<bool, is_pod<_Tp>::value> +{ }; + +template <class _Tp> +struct has_virtual_destructor : + public false_type +{ }; + +template <class _Tp> +struct is_signed : + public false_type +{ }; + +__SPEC_FULL(is_signed,signed char,true); +__SPEC_FULL(is_signed,short,true); +__SPEC_FULL(is_signed,int,true); +__SPEC_FULL(is_signed,long,true); +__SPEC_FULL(is_signed,long long,true); + +template <class _Tp> +struct is_unsigned : + public false_type +{ }; + +__SPEC_FULL(is_unsigned,unsigned char,true); +__SPEC_FULL(is_unsigned,unsigned short,true); +__SPEC_FULL(is_unsigned,unsigned int,true); +__SPEC_FULL(is_unsigned,unsigned long,true); +__SPEC_FULL(is_unsigned,unsigned long long,true); + #undef __SPEC_FULL #undef __SPEC_ #undef __SPEC_FULL1 #undef __SPEC_1 +#undef __SPEC_FULL2 +#undef __SPEC_2 } // namespace tr1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[complement-svn] SF.net SVN: complement: [1663]
trunk/complement/explore/include/misc/ type_traits.h
From: <com...@us...> - 2007-08-03 10:42:35
|
Revision: 1663 http://complement.svn.sourceforge.net/complement/?rev=1663&view=rev Author: complement Date: 2007-08-03 03:42:32 -0700 (Fri, 03 Aug 2007) Log Message: ----------- fix for gcc 3.3.6 Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-03 10:09:12 UTC (rev 1662) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-03 10:42:32 UTC (rev 1663) @@ -59,9 +59,9 @@ #define __SPEC_FULL1(C,T,B) \ __SPEC_1(C,T,B); \ -__SPEC_1(C,const T,B); \ -__SPEC_1(C,volatile T,B); \ -__SPEC_1(C,const volatile T,B) +__SPEC_1(C,T const,B); \ +__SPEC_1(C,T volatile,B); \ +__SPEC_1(C,T const volatile,B) #define __SPEC_2(C,T,B) \ template <class _Tp1, class _Tp2> \ @@ -71,9 +71,9 @@ #define __SPEC_FULL2(C,T,B) \ __SPEC_2(C,T,B); \ -__SPEC_2(C,const T,B); \ -__SPEC_2(C,volatile T,B); \ -__SPEC_2(C,const volatile T,B) +__SPEC_2(C,T const,B); \ +__SPEC_2(C,T volatile,B); \ +__SPEC_2(C,T const volatile,B) template <class _Tp> struct is_void : @@ -170,15 +170,55 @@ public false_type { }; -_SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); +// _SPEC_FULL2(is_member_object_pointer, _Tp1 _Tp2::*,!is_function<_Tp1>::value); +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::*> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::* const> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::* volatile> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_object_pointer<_Tp1 _Tp2::* const volatile> : + public integral_constant<bool, !is_function<_Tp1>::value> +{ }; + template <class _Tp> struct is_member_function_pointer : public false_type { }; -_SPEC_FULL2(is_member_function_pointer, _Tp1 _Tp2::*,is_function<_Tp1>::value); +// _SPEC_FULL2(is_member_function_pointer,_Tp1 _Tp2::*,is_function<_Tp1>::value); +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::*> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::* const> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::* volatile> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + +template <class _Tp1, class _Tp2> +struct is_member_function_pointer<_Tp1 _Tp2::* const volatile> : + public integral_constant<bool, is_function<_Tp1>::value> +{ }; + template <class _Tp> struct is_member_pointer : public integral_constant<bool, (is_member_object_pointer<_Tp>::value || is_member_function_pointer<_Tp>::value)> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[complement-svn] SF.net SVN: complement: [1692]
trunk/complement/explore/include/misc/ type_traits.h
From: <com...@us...> - 2007-08-17 15:01:44
|
Revision: 1692 http://complement.svn.sourceforge.net/complement/?rev=1692&view=rev Author: complement Date: 2007-08-17 08:01:43 -0700 (Fri, 17 Aug 2007) Log Message: ----------- gcc 4.1.2 problems? Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-17 12:56:26 UTC (rev 1691) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-17 15:01:43 UTC (rev 1692) @@ -20,7 +20,7 @@ // libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, // libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, // while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead -# if 1 /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ +# if defined(STLPORT) || (defined(__GNUC__) && (__GNUC__ < 4)) /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ namespace std { @@ -49,11 +49,18 @@ static __t2 __test(...); public: - static const bool __value; // = sizeof(__test<_Tp>(0)) == 1; +#if defined(__GNUC__) && (__GNUC__ < 4) + static const bool __value; +#else + static const bool __value = sizeof(__test<_Tp>(0)) == 1; +#endif + }; +#if defined(__GNUC__) && (__GNUC__ < 4) template <class _Tp> const bool __instance<_Tp>::__value = sizeof(__instance<_Tp>::__test<_Tp>(0)) == 1; +#endif template <class T> struct __uoc_aux : // union or class @@ -67,11 +74,17 @@ static __t2 __test(...); public: - static const bool __value; // = sizeof(__test<T>(0)) == 1; +#if defined(__GNUC__) && (__GNUC__ < 4) + static const bool __value; +#else + static const bool __value = sizeof(__test<T>(0)) == 1; +#endif }; +#if defined(__GNUC__) && (__GNUC__ < 4) template <class T> const bool __uoc_aux<T>::__value = sizeof(__uoc_aux<T>::__test<T>(0)) == 1; +#endif template <class T> class __empty @@ -624,7 +637,7 @@ } // namespace std -# else // __GLIBCXX__ && (__GNUC__ >= 4) +# else // __GLIBCXX__ && (__GNUC__ >= 4) && !STLPORT # include <tr1/type_traits> # endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[complement-svn] SF.net SVN: complement: [1819]
trunk/complement/explore/include/misc/ type_traits.h
From: <com...@us...> - 2008-02-27 14:18:34
|
Revision: 1819 http://complement.svn.sourceforge.net/complement/?rev=1819&view=rev Author: complement Date: 2008-02-27 06:18:00 -0800 (Wed, 27 Feb 2008) Log Message: ----------- is_[rl]value_reference added; is_object changed Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2008-02-27 14:13:55 UTC (rev 1818) +++ trunk/complement/explore/include/misc/type_traits.h 2008-02-27 14:18:00 UTC (rev 1819) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/11/24 00:28:34 ptr> +// -*- C++ -*- Time-stamp: <07/12/02 19:55:42 ptr> /* * Copyright (c) 2007 @@ -256,6 +256,26 @@ __CV_SPEC_1(is_pointer,_Tp *,true); template <class _Tp> +struct is_lvalue_reference : + public false_type +{ }; + +template <class _Tp> +struct is_lvalue_reference<_Tp&> : + public true_type +{ }; + +template <class _Tp> +struct is_rvalue_reference : + public false_type +{ }; + +// template <class _Tp> +// struct is_rvalue_reference<_Tp&&> : +// public true_type +// { }; + +template <class _Tp> struct is_reference : public false_type { }; @@ -374,8 +394,11 @@ template <class _Tp> struct is_object : - public integral_constant<bool, !(is_function<_Tp>::value || is_reference<_Tp>::value - || is_void<_Tp>::value)> + public integral_constant<bool, (is_arithmetic<_Tp>::value || + is_array<_Tp>::value || + is_pointer<_Tp>::value || + is_member_pointer<_Tp>::value || + detail::__is_union_or_class<_Tp>::value)> { }; template <class _Tp> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |