<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                STL定義了五個全局函數,作用于未初始化的空間上。 其中兩個全局函數construct()和destroy()負責對象的構造和析構,它們隸屬于STL標準規范。 構造對象直接使用定位new: ~~~ template <class T1, class T2> inline void construct(T1* p, const T2& value) { new (p) T1(value); // 定位new } ~~~ 析構對象分多個版本 版本1: ~~~ template <class T> inline void destroy(T* pointer) { pointer->~T(); // 直接調用析構函數 } ~~~ 版本2: ~~~ template <class ForwardIterator> inline void destroy(ForwardIterator first, ForwardIterator last) { __destroy(first, last, value_type(first)); } ~~~ 它調用: ~~~ template <class ForwardIterator, class T> inline void __destroy(ForwardIterator first, ForwardIterator last, T*) { typedef typename __type_traits<T>::has_trivial_destructor trivial_destructor; // 這里使用了萃取器 __destroy_aux(first, last, trivial_destructor()); } ~~~ 再根據對象有無必要析構分別調用: ~~~ template <class ForwardIterator> inline void __destroy_aux(ForwardIterator first, ForwardIterator last, __false_type) { // non-trivial destructor for ( ; first < last; ++first) destroy(&*first); // 逐個調用析構函數 } template <class ForwardIterator> inline void __destroy_aux(ForwardIterator, ForwardIterator, __true_type) {} // trivial destructor ~~~ 另外還有兩個版本2的重載版本: ~~~ // 兩個重載版本,無需析構 inline void destroy(char*, char*) {} inline void destroy(wchar_t*, wchar_t*) {} ~~~ 很顯然,對象為字符,則什么也不做。 另外三個全局函數: - uninitialized_copy - uninitialized_fill - uninitialized_fill_n 這三個函數都有不同的重載版本,根據元素是否為POD(傳統C struct類型),執行相應的操作,或者直接memmove(),或者調用STL泛型函數,或者分別對每個元素調用構造函數。P77的圖已經概括的非常好了。詳情參見《“類型萃取器”__type_traits》。 參考: 《STL源碼剖析》 P51、P70.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看