X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=include%2Fc%2B%2B%2Fstl%2Fstl%2Fboost_type_traits.h;fp=include%2Fc%2B%2B%2Fstl%2Fstl%2Fboost_type_traits.h;h=e41cc41ace39785154eb6ddc6ac4d4caad8a595a;hp=0000000000000000000000000000000000000000;hb=173d8903eb9d51a4ea7d7fa3e52dc86c9bb6d4f1;hpb=b024710fe2b60cd4a42a8993b61333d6cdb56ca3 diff --git a/include/c++/stl/stl/boost_type_traits.h b/include/c++/stl/stl/boost_type_traits.h new file mode 100644 index 0000000..e41cc41 --- /dev/null +++ b/include/c++/stl/stl/boost_type_traits.h @@ -0,0 +1,143 @@ +/* + * + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_BOOST_TYPE_TRAITS_H +#define _STLP_BOOST_TYPE_TRAITS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * This file mostly wraps boost type_traits in the STLport type_traits. + * When checking a type traits like trivial assign operator for instance + * both the boost value and STLport values has to be taken into account + * as we don't know what the user might have prefer, specializing the boost + * type traits or the STLport one. + */ +_STLP_BEGIN_NAMESPACE + +template struct _IsRef { + enum { _Is = ::boost::is_reference<_Tp>::value }; + typedef typename __bool2type<_Is>::_Ret _Ret; +}; + +template struct _IsPtr { + enum { is_pointer = ::boost::is_pointer<_Tp>::value }; + typedef typename __bool2type::_Ret _Ret; +}; + +template struct _IsIntegral { + enum { is_integral = ::boost::is_integral<_Tp>::value }; + typedef typename __bool2type::_Ret _Ret; +}; + +template struct _IsRational { + enum { is_float = ::boost::is_float<_Tp>::value }; + typedef typename __bool2type::_Ret _Ret; +}; + +template +struct __type_traits { + enum { trivial_constructor = ::boost::has_trivial_constructor<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_default_constructor; + + enum { trivial_copy = ::boost::has_trivial_copy<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_copy_constructor; + + enum { trivial_assign = ::boost::has_trivial_assign<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_assignment_operator; + + enum { trivial_destructor = ::boost::has_trivial_destructor<_Tp>::value }; + typedef typename __bool2type::_Ret has_trivial_destructor; + + enum { pod = ::boost::is_pod<_Tp>::value }; + typedef typename __bool2type::_Ret is_POD_type; +}; + +template +struct _TrivialCopy { + typedef typename ::boost::remove_cv<_Tp1>::type uncv1; + typedef typename ::boost::remove_cv<_Tp2>::type uncv2; + + enum { same = ::boost::is_same::value }; + typedef typename __bool2type::_Ret _Same; + + enum { boost_trivial_assign = ::boost::has_trivial_assign::value }; + typedef typename __bool2type::_Ret _BoostTrivialAssign; + typedef typename __type_traits::has_trivial_assignment_operator _STLPTrivialAssign; + typedef typename _Lor2<_BoostTrivialAssign, _STLPTrivialAssign>::_Ret _TrivialAssign; + + typedef typename _Land2<_Same, _TrivialAssign>::_Ret _Type; + static _Type _Answer() { return _Type(); } +}; + +template +struct _TrivialUCopy { + typedef typename ::boost::remove_cv<_Tp1>::type uncv1; + typedef typename ::boost::remove_cv<_Tp2>::type uncv2; + + enum { same = ::boost::is_same::value }; + typedef typename __bool2type::_Ret _Same; + + enum { boost_trivial_copy = ::boost::has_trivial_copy::value }; + typedef typename __bool2type::_Ret _BoostTrivialCopy; + typedef typename __type_traits::has_trivial_copy_constructor _STLPTrivialCopy; + typedef typename _Lor2<_BoostTrivialCopy, _STLPTrivialCopy>::_Ret _TrivialCopy; + + typedef typename _Land2<_Same, _TrivialCopy>::_Ret _Type; + static _Type _Answer() { return _Type(); } +}; + +template +struct _DefaultZeroValue { + enum { is_integral = ::boost::is_integral<_Tp>::value }; + typedef typename __bool2type::_Ret _IsIntegral; + enum { is_float = ::boost::is_float<_Tp>::value }; + typedef typename __bool2type::_Ret _IsFloat; + enum { is_pointer = ::boost::is_pointer<_Tp>::value }; + typedef typename __bool2type::_Ret _IsPointer; + + typedef typename _Lor3<_IsIntegral, _IsFloat, _IsPointer>::_Ret _Ret; +}; + +template +struct _TrivialInit { + typedef typename ::boost::remove_cv<_Tp>::type uncv; + + enum { boost_trivial_constructor = ::boost::has_trivial_constructor::value }; + typedef typename __bool2type::_Ret _BoostTrivialInit; + typedef typename __type_traits::has_trivial_default_constructor _STLPTrivialInit; + typedef typename _Lor2<_BoostTrivialInit, _STLPTrivialInit>::_Ret _Tr1; + + typedef typename _DefaultZeroValue<_Tp>::_Ret _Tr2; + typedef typename _Not<_Tr2>::_Ret _Tr3; + + typedef typename _Land2<_Tr1, _Tr3>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +_STLP_END_NAMESPACE + +#endif /* _STLP_BOOST_TYPE_TRAITS_H */