STL Source Profiling-Configurator (Memory splitter)

Source: Internet
Author: User


Global constructs and destructors:
Template <class _t1, class _t2>inline void _construct (_t1* __p, const _t2& __value) {new ((void*) __p) _t1 (__v                Alue); Placement new Operator: The constructor object is constructed on the allocated memory. Opreator New, new opreator,placement new difference please <a Target=_blank href= "http://www.cnblogs.com/luxiaoxun/archive/2012/ 08/10/2631812.html ">google</a>}template <class _t1>inline void _construct (_T1* __p) {new ((void*) __p) _ T1 ();} Template <class _tp>inline void _destroy (_tp* __pointer) {__POINTER-&GT;~_TP ();} Template <class _forwarditerator>void__destroy_aux (_forwarditerator __first, _forwarditerator __last, __false_ Type) {for (; __first! = __last; ++__first) Destroy (&*__first);} Template <class _forwarditerator> inline void __destroy_aux (_forwarditerator, _forwarditerator, __true_type) {} Template <class _forwarditerator, class _tp>inline void __destroy (_forwarditerator __first, _forwarditerator __ Last, _tp*) {typedef typename __TYPE_TRAITS&LT;_TP&GT;::HAS_TRIVIAL_DEStructor _trivial_destructor; __destroy_aux (__first, __last, _trivial_destructor ());} Template <class _forwarditerator>inline void _destroy (_forwarditerator __first, _forwarditerator __last) {__ Destroy (__first, __last, __value_type (__first));}
inline void _destroy (char*, char*) {}inline void _destroy (int*, int*) {}inline void _destroy (long*, long*) {}inline void _ Destroy (float*, float*) {}inline void _destroy (double*, double*) {} #ifdef __stl_has_wchar_tinline void _destroy (wchar_t *, wchar_t*) {}



To globally replicate and populate bulk data functions:
Files: Stl_uninitialized.h Analyze one of the many functions: the Uninitialized_copy function. There are three versions of this function: a template function, a char type overload, and a WCHAR type overload. Please see for details. Char type overloading: inline char* uninitialized_copy (const char* __first, const char* __last,char* __result) {memmove (__result, __fi  RST, __last-__first); return __result + (__last-__first);} WCHAR type overloading: inline wchar_t* uninitialized_copy (const wchar_t* __first, const wchar_t* __last,wchar_t* __result) {memmove (  __result, __first, sizeof (wchar_t) * (__last-__first)); return __result + (__last-__first);} Template type: Using the Type feature extraction template <class _inputiter, class _forwarditer>inline _forwarditer uninitialized_copy (_inputiter __first, _inputiter __last, _forwarditer __result) {return __uninitialized_copy (__first, __last, __result,__VALUE_TYPE (__result));} Template <class _inputiter, class _forwarditer, Class _tp>inline _forwarditer__uninitialized_copy (_InputIter __  First, _inputiter __last,_forwarditer __result, _tp*) {typedef typename __type_traits<_tp>::is_pod_type _Is_POD; Return __uninitialized_copy_aux (__first, __last, __result, _is_pod ());} Template <class _inputiter, class _forwarditer>inline _forwarditer __uninitialized_copy_aux (_InputIter __first, _inputiter __last,_forwarditer __result,__true_type) {return copy (__first, __last, __result);} Template <class _inputiter, class _forwarditer>_forwarditer __uninitialized_copy_aux (_inputiter __first, _ Inputiter __last, _forwarditer __result, __false_type) {_forwarditer __CU  R = __result;    __stl_try {for (; __first! = __last; ++__first, ++__cur) _construct (&*__cur, *__first);  return __cur; } __stl_unwind (_destroy (__result, __cur));}

Level one or two memory allocator (with malloc)

Concrete See STL Source file: stl_alloc.h

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

STL Source Profiling-Configurator (Memory splitter)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.