• <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 閱讀(252) 評論(0)  編輯 收藏 引用 所屬分類: C++ programme language
            久久se精品一区二区| 久久久久AV综合网成人| 久久www免费人成精品香蕉| 久久精品国产99国产精偷| 久久久久国产精品麻豆AR影院| 久久久国产精华液| 中文无码久久精品| 99久久人人爽亚洲精品美女| 久久国内免费视频| 国产精品视频久久| 97久久国产露脸精品国产| 999久久久国产精品| 亚洲av日韩精品久久久久久a| 夜夜亚洲天天久久| 久久夜色精品国产网站| 久久久久亚洲精品中文字幕| 久久精品国产网红主播| 久久无码中文字幕东京热| 久久久久久久久久久免费精品 | 久久精品国产精品亚洲下载 | 久久99毛片免费观看不卡| 久久久久亚洲av成人网人人软件| 久久久青草青青亚洲国产免观| 久久精品久久久久观看99水蜜桃| 中文字幕亚洲综合久久2| 久久婷婷五月综合97色一本一本| 伊人久久大香线蕉无码麻豆 | 一本色综合网久久| 亚洲国产高清精品线久久| 久久996热精品xxxx| 亚洲成人精品久久| 国产99久久久国产精免费| 久久精品国产亚洲av麻豆色欲| 国产成人无码精品久久久性色| 激情五月综合综合久久69| 久久精品国产黑森林| 久久本道久久综合伊人| 精品久久人人妻人人做精品| 欧美亚洲另类久久综合婷婷| 久久99久久成人免费播放| 久久精品国产男包|