[complement-svn] SF.net SVN: complement:[1962] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-09-08 19:54:53
|
Revision: 1962 http://complement.svn.sourceforge.net/complement/?rev=1962&view=rev Author: complement Date: 2008-09-08 19:54:51 +0000 (Mon, 08 Sep 2008) Log Message: ----------- add enable_if, conditional and decay Use some things that I made for STLport; useful when no STLport and gcc before 4.x. Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h trunk/complement/explore/lib/misc/ChangeLog Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2008-09-08 19:54:20 UTC (rev 1961) +++ trunk/complement/explore/include/misc/type_traits.h 2008-09-08 19:54:51 UTC (rev 1962) @@ -707,6 +707,67 @@ // aligned_storage +namespace detail { + +template <bool,class _U> +struct _decay_aux2 +{ + typedef typename remove_cv<_U>::type type; +}; + +template <class _U> +struct _decay_aux2<true,_U> +{ + typedef typename add_pointer<_U>::type type; +}; + +template <bool, class _U> +struct _decay_aux1 +{ + typedef typename _decay_aux2<is_function<_U>::value,_U>::type type; +}; + +template <class _U> +struct _decay_aux1<true,_U> +{ + typedef typename remove_extent<_U>::type* type; +}; + +} // namespace detail + +template <class _Tp> +class decay +{ + private: + typedef typename remove_reference<_Tp>::type _U; + + public: + typedef typename detail::_decay_aux1<is_array<_U>::value,_U>::type type; +}; + +template <bool, class _Tp = void> +struct enable_if +{ +}; + +template <class _Tp> +struct enable_if<true,_Tp> +{ + typedef _Tp type; +}; + +template <bool, class _Tp1, class _Tp2> +struct conditional +{ + typedef _Tp2 type; +}; + +template <class _Tp1, class _Tp2> +struct conditional<true,_Tp1,_Tp2> +{ + typedef _Tp1 type; +}; + #undef __CV_SPEC #undef __SPEC_ #undef __CV_SPEC_1 Modified: trunk/complement/explore/lib/misc/ChangeLog =================================================================== --- trunk/complement/explore/lib/misc/ChangeLog 2008-09-08 19:54:20 UTC (rev 1961) +++ trunk/complement/explore/lib/misc/ChangeLog 2008-09-08 19:54:51 UTC (rev 1962) @@ -1,3 +1,8 @@ +2008-09-08 Petr Ovtchenkov <pt...@vo...> + + * type_traits.h: add enable_if, conditional and decay; + useful when no STLport and gcc before 4.x. + 2008-07-21 Petr Ovtchenkov <pt...@is...> * type_traits.h: fix STLport version; use type_traits This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |