• <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>

            Error

            C++博客 首頁 新隨筆 聯系 聚合 管理
              217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks

            // 如果參數為const int&類型,就會掛掉。據說是編譯器實現的時候忽略了?
            // 具體分析錯誤應該是這樣: std::ptr_fun會構造出一個派生于binary_function的對象,
            // 傳遞給他的模板參數就是函數參數類型,如果傳遞&類型,會導致調用真是函數時候
            // argument_type&變成argument_type&&引發編譯錯誤,除非能在std::prt_fun中推導出
            // Val&參數類型中的Val類型作為模板參數傳遞下去
            bool Cmp(const int& iLeft, const int& iRight)
            {
                return true;
            }

            // std::binary_functiond在傳遞函數參數的時候已經分別生命了const TVal& 和 TVal&兩個版本,
            // 所以在實例化的時候不能傳遞const TVal&上去,會造成編譯錯誤
            class Functor_Cmp : public std::binary_function<int, int, bool>
            {
            public:
                bool operator () (const int& iLeft, const int& iRight) const
                {
                    return true;
                }
            };

            void Test_Bind2end()
            {
                vector<int> vInt(9);

                // 注意functor 和function ptr的區別
                std::count_if(vInt.begin(), vInt.end(), std::bind2nd(std::ptr_fun(&Cmp), 1));
                std::count_if(vInt.begin(), vInt.end(), std::bind2nd(Functor_Cmp(), 1));
            }

            posted on 2013-10-04 16:21 Enic 閱讀(1495) 評論(1)  編輯 收藏 引用 所屬分類: 理解stl

            評論

            # re: std::bind2nd簡單理解 2014-03-16 19:02 Enic
            1.std::bind2nd std::bind1st 用于參數綁定
            2.std::binary_function 等用于支持std::bind2nd std::bind1st
            3.std::mem_fun1用于從普通函數構造出派生于binary_function臨時對象支持bind系列  回復  更多評論
              

            国产精品内射久久久久欢欢| 久久AⅤ人妻少妇嫩草影院| 久久精品综合网| 亚洲综合日韩久久成人AV| 久久99亚洲网美利坚合众国| 国产成人久久精品麻豆一区| 免费精品国产日韩热久久| A狠狠久久蜜臀婷色中文网| 亚洲国产香蕉人人爽成AV片久久| 久久人人爽人人爽人人AV东京热| 色综合久久最新中文字幕| 久久亚洲精品国产精品婷婷| 久久综合久久综合久久| 久久久亚洲裙底偷窥综合| 久久er国产精品免费观看8| 久久久久久久久无码精品亚洲日韩| 成人精品一区二区久久 | 久久人人妻人人爽人人爽| 国产精品女同一区二区久久| 亚洲AV日韩精品久久久久| 久久中文精品无码中文字幕| 久久线看观看精品香蕉国产| 国产精品久久久久久五月尺| 国内精品久久久久久久久电影网| 午夜天堂精品久久久久| 77777亚洲午夜久久多人| 日本加勒比久久精品| 久久se精品一区精品二区国产| 国产91色综合久久免费分享| 久久久久国产精品熟女影院| 国色天香久久久久久久小说| 久久精品国产乱子伦| 久久婷婷国产剧情内射白浆 | 久久人搡人人玩人妻精品首页| 久久久久久a亚洲欧洲aⅴ| 国产一区二区三区久久| 国产精品青草久久久久婷婷| 久久免费精品一区二区| 丁香五月综合久久激情| 日本欧美国产精品第一页久久| 久久久久国产日韩精品网站|