亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        瘦身前后——兼談C++語言進化(5)

        字號:

        (4)  這里function_invoker是用的type-erase手法,具體可參見我以前寫的boost.any源碼剖析,或上篇講auto的,或《C++ Template Metaprogramming》(內有元編程慎入?。?。type-erase手法是像C++這樣的弱RTTI支持的語言中少數(shù)真正實用的手法,某種程度上設計模式里面的adapter模式也是type-erase的一個變種。
            如果還覺得不夠的話,可以參考variadic-templates的主頁,上面的variadic templates proposal中帶了三個tr1實現(xiàn),分別是tuple,bind,function,當然,variadic-templates的好處遠遠不僅僅止于這三個實現(xiàn),從本質上它提供了一種真正直接的表達意圖的工具,完全避開了像下面這種horrible的workaround:
            template
            cons(T1& t1, const null_type&, const null_type&, const null_type&,
            const null_type&, const null_type&, const null_type&,
            const null_type&, const null_type&, const null_type&)
            : head (t1) {}
            tuple的C++98實現(xiàn),代碼近千行。利用variadic-templates實現(xiàn),代碼僅百行。
            和這種更horrible的workaround:
            template
            _bi::bind_t::type>
            BOOST_BIND(boost::type, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
            {
            typedef typename _bi::list_av_6::type list_type;
            return _bi::bind_t(f, list_type(a1, a2, a3, a4, a5, a6));
            }