diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlportv5/stl/_construct.h --- a/epoc32/include/stdapis/stlportv5/stl/_construct.h Wed Mar 31 12:27:01 2010 +0100 +++ b/epoc32/include/stdapis/stlportv5/stl/_construct.h Wed Mar 31 12:33:34 2010 +0100 @@ -1,5 +1,5 @@ /* - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. + * * Copyright (c) 1994 * Hewlett-Packard Company * @@ -9,13 +9,13 @@ * Copyright (c) 1997 * Moscow Center for SPARC Technology * - * Copyright (c) 1999 + * Copyright (c) 1999 * Boris Fomitchev * * 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 + * 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 @@ -30,218 +30,211 @@ #ifndef _STLP_INTERNAL_CONSTRUCT_H #define _STLP_INTERNAL_CONSTRUCT_H -#ifdef _STLP_USE_TRAP_LEAVE -#include -#endif // _STLP_USE_TRAP_LEAVE +#if !defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_INTERNAL_CSTRING) +# include +#endif -# if defined (_STLP_DEBUG_UNINITIALIZED) && ! defined (_STLP_CSTRING) -# include -# endif - -# ifndef _STLP_INTERNAL_NEW_HEADER +#ifndef _STLP_INTERNAL_NEW # include -# endif - +#endif #ifndef _STLP_INTERNAL_ITERATOR_BASE_H -# include +# include +#endif + +#ifndef _STLP_MOVE_CONSTRUCT_FWK_H +# include #endif _STLP_BEGIN_NAMESPACE -# ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG template -inline void __destroy_aux(_Tp* __pointer, const __false_type&) { __pointer->~_Tp(); } +inline void __destroy_aux(_Tp* __pointer, const __false_type& /*_Trivial_destructor*/) +{ __pointer->~_Tp(); } + template -inline void __destroy_aux(_Tp* __pointer, const __true_type&) {} -# endif +inline void __destroy_aux(_Tp*, const __true_type& /*_Trivial_destructor*/) {} template inline void _Destroy(_Tp* __pointer) { -# if _MSC_VER >= 1010 +#if defined (_STLP_MSVC) && (_STLP_MSVC <= 1010) __pointer; -# endif // _MSC_VER >= 1000 -# ifdef _STLP_TRIVIAL_DESTRUCTOR_BUG +#endif typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor; __destroy_aux(__pointer, _Trivial_destructor()); -# else -# if ( defined (__BORLANDC__) && ( __BORLANDC__ < 0x500 ) ) - __pointer->_Tp::~_Tp(); -# else - __pointer->~_Tp(); -# endif -# endif -# ifdef _STLP_DEBUG_UNINITIALIZED - memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp)); -# endif +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset(__REINTERPRET_CAST(char*, __pointer), _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif } -# if defined (new) -# define _STLP_NEW_REDEFINE new -# undef new -# endif +template +inline void _Destroy_Moved(_Tp* __pointer) { + typedef typename __move_traits<_Tp>::complete _Trivial_destructor; + __destroy_aux(__pointer, _Trivial_destructor()); +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif +} -# ifdef _STLP_DEFAULT_CONSTRUCTOR_BUG +#if defined (new) +# define _STLP_NEW_REDEFINE new +# undef new +#endif + +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG) template inline void _Construct_aux (_T1* __p, const __false_type&) { -_STLP_PLACEMENT_NEW (__p) _T1(); + _STLP_PLACEMENT_NEW (__p) _T1(); } template inline void _Construct_aux (_T1* __p, const __true_type&) { -_STLP_PLACEMENT_NEW (__p) _T1(0); + _STLP_PLACEMENT_NEW (__p) _T1(0); } -# endif - -template -inline void _Construct(_T1* __p, const _T2& __val) { -# ifdef _STLP_DEBUG_UNINITIALIZED - memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); -# endif - _STLP_PLACEMENT_NEW (__p) _T1(__val); -} +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */ template inline void _Construct(_T1* __p) { -# ifdef _STLP_DEBUG_UNINITIALIZED +#if defined (_STLP_DEBUG_UNINITIALIZED) memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); -# endif -# ifdef _STLP_DEFAULT_CONSTRUCTOR_BUG -typedef typename _Is_integer<_T1>::_Integral _Is_Integral; -_Construct_aux (__p, _Is_Integral() ); -# else +#endif +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG) + _Construct_aux (__p, _HasDefaultZeroValue(__p)._Answer() ); +#else _STLP_PLACEMENT_NEW (__p) _T1(); -# endif +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */ } -# if defined(_STLP_NEW_REDEFINE) -# ifdef DEBUG_NEW -# define new DEBUG_NEW -# endif -# undef _STLP_NEW_REDEFINE -# endif - -template -_STLP_INLINE_LOOP void -__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, const __false_type&) { - for ( ; __first != __last; ++__first) - _STLP_STD::_Destroy(&*__first); +template +inline void _Copy_Construct(_Tp* __p, const _Tp& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif + _STLP_PLACEMENT_NEW (__p) _Tp(__val); } -template -inline void __destroy_aux(_ForwardIterator, _ForwardIterator, const __true_type&) {} +template +inline void _Param_Construct(_T1* __p, const _T2& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif + _STLP_PLACEMENT_NEW (__p) _T1(__val); +} + +template +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __false_type& /*_IsPOD*/) { + _STLP_PLACEMENT_NEW (__p) _T1(_STLP_PRIV _AsMoveSource(__val)); +} + +template +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __true_type& /*_IsPOD*/) { + _STLP_PLACEMENT_NEW (__p) _T1(__val); +} + +template +inline void _Move_Construct(_T1* __p, _T2& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif + _Move_Construct_Aux(__p, __val, _Is_POD(__p)._Answer()); +} + +#if defined(_STLP_NEW_REDEFINE) +# if defined (DEBUG_NEW) +# define new DEBUG_NEW +# endif +# undef _STLP_NEW_REDEFINE +#endif template -inline void -__destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) { +_STLP_INLINE_LOOP void +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __false_type& /*_Trivial_destructor*/) { + for ( ; __first != __last; ++__first) { + __destroy_aux(&(*__first), __false_type()); +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif + } +} + +template +#if defined (_STLP_DEBUG_UNINITIALIZED) +_STLP_INLINE_LOOP void +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __true_type& /*_Trivial_destructor*/) { + for ( ; __first != __last; ++__first) + memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp)); +} +#else +inline void +__destroy_range_aux(_ForwardIterator, _ForwardIterator, _Tp*, const __true_type& /*_Trivial_destructor*/) {} +#endif + +template +inline void +__destroy_range(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) { typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor; - __destroy_aux(__first, __last, _Trivial_destructor()); + __destroy_range_aux(__first, __last, __ptr, _Trivial_destructor()); } template -inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) { - __destroy(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); +inline void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last) { + __destroy_range(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); } -inline void _Destroy(char*, char*) {} -# ifdef _STLP_HAS_WCHAR_T // dwa 8/15/97 -inline void _Destroy(wchar_t*, wchar_t*) {} -inline void _Destroy(const wchar_t*, const wchar_t*) {} -# endif +inline void _Destroy_Range(char*, char*) {} +#if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97 +inline void _Destroy_Range(wchar_t*, wchar_t*) {} +inline void _Destroy_Range(const wchar_t*, const wchar_t*) {} +#endif -# ifndef _STLP_NO_ANACHRONISMS +template +inline void +__destroy_mv_srcs(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) { + typedef typename __move_traits<_Tp>::complete _CompleteMove; + __destroy_range_aux(__first, __last, __ptr, _CompleteMove()); +} + +template +inline void _Destroy_Moved_Range(_ForwardIterator __first, _ForwardIterator __last) { + __destroy_mv_srcs(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); +} + +#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG) +// Those adaptors are here to fix common compiler bug regarding builtins: +// expressions like int k = int() should initialize k to 0 +template +inline _Tp __default_constructed_aux(_Tp*, const __false_type&) { + return _Tp(); +} +template +inline _Tp __default_constructed_aux(_Tp*, const __true_type&) { + return _Tp(0); +} + +template +inline _Tp __default_constructed(_Tp* __p) { + return __default_constructed_aux(__p, _HasDefaultZeroValue(__p)._Answer()); +} + +# define _STLP_DEFAULT_CONSTRUCTED(_TTp) __default_constructed((_TTp*)0) +#else +# define _STLP_DEFAULT_CONSTRUCTED(_TTp) _TTp() +#endif /* _STLP_DEF_CONST_DEF_PARAM_BUG */ + + +#if !defined (_STLP_NO_ANACHRONISMS) // -------------------------------------------------- // Old names from the HP STL. template -inline void construct(_T1* __p, const _T2& __val) {_Construct(__p, __val); } +inline void construct(_T1* __p, const _T2& __val) {_Param_Construct(__p, __val); } template -inline void construct(_T1* __p) { _Construct(__p); } +inline void construct(_T1* __p) { _STLP_STD::_Construct(__p); } template inline void destroy(_Tp* __pointer) { _STLP_STD::_Destroy(__pointer); } template -inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy(__first, __last); } -# endif - -#ifdef _STLP_USE_TRAP_LEAVE - -struct TCleanupOverlay -{ - TAny *vtable; - TAny *iBase; - TAny *iTop; - TAny *iNext; -}; - -template -struct _STLP_StackHelper { - static unsigned int Check( void *ptr ); - static void* _NewLC (size_t __n); -}; - -struct _STLP_StackPopper { - ~_STLP_StackPopper() { CleanupStack::Pop(); } -}; - -template -struct _STLP_Cleanup { - static void clear(TAny* __p); -}; - -# define _STLP_PUSH_CLEANUP_ITEM(_Tp, __p) CleanupStack::PushL(TCleanupItem(&_STLP_Cleanup< _Tp >::clear, (TAny*)__p)); -# define _STLP_PUSH_STACK_ITEM(_Tp, __p) _STLP_PUSH_CLEANUP_ITEM(_Tp, __p) _STLP_StackPopper __Popper; _STLP_no_unused_variable_warning( __Popper ); -# define _STLP_POP_IF_CHECK if (_STLP_StackHelper::Check(this)) CleanupStack::Pop(); -# define _STLP_POP_CLEANUP_ITEM CleanupStack::Pop(); _STLP_POP_IF_CHECK - -# define _STLP_POP_ITEM CleanupStack::Pop(); - -// to be used in complex object constructors -template -struct _STLP_StackPusher { - _STLP_StackPusher(_Tp * __p) { _STLP_PUSH_CLEANUP_ITEM(_Tp, (void*)__p) } -}; - -template -unsigned int _STLP_StackHelper<_Tp>::Check( void *ptr ) - -{ - TCleanupTrapHandler *handler = - (TCleanupTrapHandler *)User::TrapHandler(); - - CCleanup &cleanup = handler->Cleanup(); - - TCleanupOverlay *overlay = (TCleanupOverlay *)( &cleanup ); - - char *raw = (char *)(overlay->iNext) - 4; - void *topptr = *( (void **)(raw) ); - - return ( ptr == topptr ); -} - - -template -void* _STLP_StackHelper<_Tp>::_NewLC(size_t __n) { - void* __p = ::operator new (__n, ELeave) ; - // constructor will pop it back - CleanupStack::PushL(__p); - return __p; -} - -template -void _STLP_Cleanup<_Tp>::clear(TAny* __p) -{ - ((_Tp*)__p)->~_Tp(); -} - - -#else -# define _STLP_PUSH_CLEANUP_ITEM(_Tp, __p) -# define _STLP_POP_CLEANUP_ITEM -# define _STLP_PUSH_STACK_ITEM(_Tp, p) -# define _STLP_POP_ITEM -# define _STLP_POP_IF_CHECK -# define TPush TLeave -#endif +inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy_Range(__first, __last); } +#endif /* _STLP_NO_ANACHRONISMS */ _STLP_END_NAMESPACE