• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Operator new allocates memory from the heap, on which an object is constructed. Standard C++ also supports placement new operator, which constructs an object on a pre-allocated buffer. This is useful when building a memory pool, a garbage collector or simply when performance and exception safety are paramount (there's no danger of allocation failure since the memory has already been allocated, and constructing an object on a pre-allocated buffer takes less time):
             void placement() {

            char *buf = new char[1000]; //pre-allocated buffer

            string *p = new (buf) string("hi"); //placement new

            string *q = new string("hi"); //ordinary heap allocation

            cout<
            <
            c_str()
            <
            <c_str();

            }

            placement new 表達式只是定位,不存在與其相對應的delete,如果delete則選擇
            delete[] buf。


            michalegao 2008-06-05 12:03 發表評論

            文章來源:http://www.cnblogs.com/michael-gao/archive/2008/06/05/1214239.html
            Posted on 2008-06-05 15:59 micheal's tech 閱讀(251) 評論(0)  編輯 收藏 引用 所屬分類: C++ programme language
            精品久久久久久久久久中文字幕 | 久久国产免费直播| 国产精品欧美久久久天天影视| 中文字幕一区二区三区久久网站| 久久黄视频| 亚洲精品无码久久久久去q| 亚洲狠狠综合久久| 欧美久久久久久| 91精品无码久久久久久五月天| 久久午夜免费视频| 久久精品草草草| 中文字幕乱码久久午夜| 久久久WWW成人免费精品| 无码日韩人妻精品久久蜜桃| 久久婷婷五月综合色99啪ak| 久久亚洲精品人成综合网| 久久精品国产欧美日韩| 国产午夜精品久久久久免费视| 国产精品久久久久久久人人看| 99久久人人爽亚洲精品美女| 精品久久久噜噜噜久久久| 2021国产精品午夜久久| 久久久无码精品亚洲日韩软件| 99久久精品国产高清一区二区 | 久久久精品波多野结衣| 久久精品国产亚洲av水果派| 精品久久久久久久久免费影院| 久久精品成人免费观看97| 亚洲国产成人久久精品动漫| 精品久久久久久中文字幕人妻最新| 中文字幕精品久久| 久久成人小视频| 女人高潮久久久叫人喷水| 日韩va亚洲va欧美va久久| 久久人人爽人爽人人爽av | 精品久久久久久| 精品久久久久中文字幕日本 | 无码人妻少妇久久中文字幕 | 国产午夜福利精品久久2021| 久久亚洲私人国产精品vA| 国产亚洲色婷婷久久99精品|