Filename:stl_construct.h//Comment by: Frost//e-mail:mdl2009@vip.qq.com//Blog:http://blog.csdn.ne t/mdl13412 * * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and S Ell this software * and it documentation for all purpose is hereby granted without-fee, * provided that above Copyr ight notice appear in all copies and * so both that the copyright notice and this permission notice appear * in supporting Documentation. Hewlett-Packard Company makes no * representations about the suitability of this software to any * purpose.
It is provided ' as is ' without express or implied warranty.
* * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby Granted without fee, * provided that above copyright notice appear in all copies and * that both IcE and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software to any * purpose.
It is provided ' as is ' without express or implied warranty.
*/* Note:this is a internal header file, included by the other STL headers.
* You should not attempt to use it directly. * * #ifndef __sgi_stl_internal_construct_h #define __SGI_STL_INTERNAL_CONSTRUCT_H #include <new.h>//Need plac Ement New prototype __stl_begin_namespace//Call member destructor, requires type with non-trivial destructor template <class t> inline void destr
Oy (t* pointer) {pointer->~t ();} Use placement new to construct the object on the allocated memory//If you are unfamiliar with placement new, please refer to//http://msdn.microsoft.com/en-us/library/kewsb8ba.aspx// http://blogs.msdn.com/b/jaredpar/archive///2007/10/16/c-new-operator-and-placement-new.aspx template <class T1
, class t2> inline void construct (t1* p, const t2& value) {new (P) T1 (value);} destructor a set of objects used to have NON-TRivial destructor template <class forwarditerator> inline void __destroy_aux (forwarditerator
ForwardIterator, __false_type) {for (; i < last; ++first) destroy (&*first);} If there is no type non-trivial destructor, use this function template <class forwarditerator> inline void __destroy_aux ( ForwardIterator, ForwardIterator, __true_type) {}//Use traits technology to determine whether the type has non-trivial destructor, and then call a different function template < Class ForwardIterator, class t> inline void __destroy (ForwardIterator, ForwardIterator, last, t*) {typedef type
Name __type_traits<t>::has_trivial_destructor Trivial_destructor;
__destroy_aux (The Last, Trivial_destructor ()); //////////////////////////////////////////////////////////////////////////////////Used to destroy a set of objects////////////////////
char * Special version ----------Destroy no destructor// | Destroy (I, last)--------------------------Special//|
| // | Generalization-----------Destroy no destructor//|
wchar_t * Special version of the//↓//call __destroy (A, Last, Value_type (a));
function forwarding based on whether it has trivial destructor//|
|----------------has trivial destructor?
// | -------------------------------------------//No | | Yes//|
| ↓↓//__destroy_aux (..., __true_type) __destroy_aux (... ., __false_type)//Do not enter requires a row destructor for (; a < last; ++first)// Destroy (&*first); Template <class forwarditerator> inline void Destroy (ForwardIterator I, ForwardIterator last) {__destroy (i, Last, value_type
(i)); }//Special version inline void Destroy (char*, char*) {} inline void Destroy (wchar_t*, wchar_t*) {} __stl_end_namespace #endif/*
__sgi_stl_internal_construct_h *//local Variables://mode:c++//end: