• <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>
            posts - 18,  comments - 104,  trackbacks - 0

             

            最近最大的新聞莫過于微軟發布Visual Studio2010了,對c++的支持更進一步,其intellsence的解析也使用了和以前完全不同的方法(以前是靠編譯器,現在是獨立inellsence單元),番茄可能要被打入冷宮了。

            Stephan T. Lavavej在Visual c++ Team Blog上發布了VC10對C++0x標準的支持情況,包括:
            lambdas, auto, static_assert and rvalue references,他的博客是針對CTP版本的。

            我下載安裝了VC10 beta1 professional,感覺除了卡,沒啥不好的,新的intellsence和Java,C#一樣,即時分析代碼,并在有語法錯誤的地方畫上紅線。但是好像intellsence的語法不支持C++0x的,在右值引用,Lambda的地方,也畫紅線。


            對于Stephan T. Lavavej寫的

            Rvalue References: C++0x Features in VC10, Part 2

            我并沒有打算全部翻譯,有興趣可以讀原文,我只把我認為重要的地方翻譯出來,順序也調整了一下,水平有限,附上原文。

            C++03 3.10/1 says: "Every expression is either an lvalue or an rvalue."  It's important to remember that lvalueness versus rvalueness is a property of expressions, not of objects.
            C++03 3.10/1 提到:"任何一個表達式,不是左值,就是右值",左值或者右值是針對表達式而言的,object沒有左右值之分,應該時刻謹記這一點。

            Both lvalues and rvalues can be either modifiable (non-const) or non-modifiable (const).  Here are examples:

             左值和右值都有const 和非const之分,下面是一個例子:

             1string one("cute");
             2
             3const string two("fluffy");
             4
             5string three() return "kittens"; }
             6
             7const string four() return "are an essential part of a healthy diet"; }
             8
             9 
            10
            11one;     // modifiable lvalue
            12
            13two;     // const lvalue
            14
            15three(); // modifiable rvalue
            16
            17four();  // const rvalue
            18

            Type& binds to modifiable lvalues (and can be used to observe and mutate them). 

            Type& 只能綁定非const左值(可以觀察和修改)。

            const Type& binds to everything: modifiable lvalues, const lvalues, modifiable rvalues, and const rvalues (and can be used to observe them).

            const Type& 可以綁定所有類型:非const左值,const左值,非const右值和const右值(只可以觀察)。

            上面這些都是03的標準,然而這對move語義和完美轉發的實習,確實是一種障礙。關于move語義和完美轉發,請看《C++0x漫談》系列之:右值引用 或“move語意與完美轉發”(上)《C++0x漫談》系列之:右值引用 或“move語意與完美轉發”(下)

            move語義就是怎么能在非const右值銷毀之前,將其中仍有用的資源竊取過來,以求高效。這就需要語言本身能識別非const右值,03中,語言本身不支持,只能靠入侵的方式實現。0x中,在語言層面上得到了支持,用&&表示非const右值。下面看看0x為了支持右值,進行了那些修正。

            下面是關于函數左右值的重載決議:
            1 .  The initialization rules have veto power.

            初始化規則具有否決權(否決權指對所有候選函數,如果有參數根本不能轉化,就放棄考慮,比如把一個const type轉化為type)。

            2 .  Lvalues strongly prefer binding to lvalue references, and rvalues strongly prefer binding to rvalue references.

            左值優先綁定左值,右值優先綁定右值。

            3 .  Modifiable expressions weakly prefer binding to modifiable references.

            非const表達式趨向于綁定非const引用。

            正常情況下:
             1#include <iostream>
             2
             3#include <ostream>
             4
             5#include <string>
             6
             7using namespace std;
             8
             9 
            10
            11void meow(string& s) {
            12
            13    cout << "meow(string&): " << s << endl;
            14
            15}

            16
            17 
            18
            19void meow(const string& s) {
            20
            21    cout << "meow(const string&): " << s << endl;
            22
            23}

            24
            25 
            26
            27void meow(string&& s) {
            28
            29    cout << "meow(string&&): " << s << endl;
            30
            31}

            32
            33 
            34
            35void meow(const string&& s) {
            36
            37    cout << "meow(const string&&): " << s << endl;
            38
            39}

            40
            41 
            42
            43string strange() {
            44
            45    return "strange()";
            46
            47}

            48
            49 
            50
            51const string charm() {
            52
            53    return "charm()";
            54
            55}

            56
            57 
            58
            59int main() {
            60
            61    string up("up");
            62
            63    const string down("down");
            64
            65 
            66
            67    meow(up);
            68
            69    meow(down);
            70
            71    meow(strange());
            72
            73    meow(charm());
            74
            75}

            76
            77 
            78
            79C:\Temp>cl /EHsc /nologo /W4 four_overloads.cpp
            80
            81four_overloads.cpp
            82
            83 
            84//output
            85
            86meow(string&): up
            87
            88meow(const string&): down
            89
            90meow(string&&): strange()
            91
            92meow(const string&&): charm()
            93
            94

            In practice, overloading on Type& , const Type& , Type&& , and const Type&& is not very useful.  A far more interesting overload set is const Type& and Type&& :

            在實踐中,重載所有的4個版本沒有意義,而我們更傾向于使用const string& 和string&&:
            例子:
             1C:\Temp>type two_overloads.cpp
             2
             3#include <iostream>
             4
             5#include <ostream>
             6
             7#include <string>
             8
             9using namespace std;
            10
            11 
            12
            13void purr(const string& s) {
            14
            15    cout << "purr(const string&): " << s << endl;
            16
            17}

            18
            19 
            20
            21void purr(string&& s) {
            22
            23    cout << "purr(string&&): " << s << endl;
            24
            25}

            26
            27 
            28
            29string strange() {
            30
            31    return "strange()";
            32
            33}

            34
            35 
            36
            37const string charm() {
            38
            39    return "charm()";
            40
            41}

            42
            43 
            44
            45int main() {
            46
            47    string up("up");
            48
            49    const string down("down");
            50
            51 
            52
            53    purr(up);
            54
            55    purr(down);
            56
            57    purr(strange());
            58
            59    purr(charm());
            60
            61}

            62
            63 
            64
            65C:\Temp>cl /EHsc /nologo /W4 two_overloads.cpp
            66
            67two_overloads.cpp
            68
            69 
            70
            71// output
            72
            73purr(const string&): up
            74
            75purr(const string&): down
            76
            77purr(string&&): strange()
            78
            79purr(const string&): charm()
            80
            81


            For purr(up) , the initialization rules veto neither purr(const string&) nor purr(string&&) .  up is an lvalue, so it strongly prefers binding to the lvalue reference purr(const string&) .  up is modifiable, so it weakly prefers binding to the modifiable reference purr(string&&) .  The strongly preferred purr(const string&) wins.

            對于 purr(up) ,決議(1)沒有否決 purr(const string&) 和 purr(string&&) ,up是左值,所以依照決議(2),它優先綁定左值purr(const string&) ,依照決議(3),它趨向于綁定非const右值 purr(string&&) ,所以左值勝出:purr(const string&) 。

            For purr(down) , the initialization rules veto purr(string&&) due to const correctness, so purr(const string&) wins by default.

            對于For purr(down),決議(1)以為const否決了 purr(string&&) ,所以選擇purr(const string&)。

            For purr(strange()) , the initialization rules veto neither purr(const string&) nor purr(string&&) .  strange() is an rvalue, so it strongly prefers binding to the rvalue reference purr(string&&) .  strange() is modifiable, so it weakly prefers binding to the modifiable reference purr(string&&) .  The doubly preferred purr(string&&) wins.

             對于purr(strange()),決議(1)都沒有否決,strange() 是右值,所以依照決議(2),優先綁定右值purr(string&&),依照決議(3),strange() 是非const,趨向于綁定非const,所以purr(string&&) 兩票獲勝。

            For purr(charm()) , the initialization rules veto purr(string&&) due to const correctness, so purr(const string&) wins by default.

            對于purr(charm()), 初始化決議(1)否決了非const的purr(string&&) ,所以選擇purr(const string&) 。

            先寫這么多吧,明天再寫。
            posted on 2009-05-27 23:17 尹東斐 閱讀(1825) 評論(3)  編輯 收藏 引用

            FeedBack:
            # re: Rvalue References: C++0x Features in VC10 (一)
            2009-05-28 09:03 | 飄飄白云
            我正在譯言上翻譯Stephan T. Lavavej這一系列的三篇文章,不過剛開始翻譯第一篇,哈哈,你已經翻第二篇了,到時候借鑒了~~  回復  更多評論
              
            # re: Rvalue References: C++0x Features in VC10 (一)
            2009-05-28 16:37 | 尹東斐
            @飄飄白云

            我只是覺得這個rvalue reference是最重要的特性,可以不知不覺的增加效率,所以就決定寫點什么。  回復  更多評論
              
            # re: Rvalue References: C++0x Features in VC10 (一)[未登錄]
            2009-05-28 17:18 | king
            高薪招聘:手機游戲開發等各類手機行業人才
            職位描述: 手機游戲開發高級工程師
            要求:
            1.大專以上學歷,做手機游戲開發至少三年以上。
            2.熟悉J2ME和C++等工作專業知識

            招聘:手機軟件經理/資深工程師
            職位描述:
            1. 至少三年以上手機制造企業或相關企業專職開發工作經驗,熟悉下列手機開發平臺一種或多種:MTK,展訊,英飛凌,coolsand平臺,google的android或其他開發平臺
            2. 熟悉 c/c++,對 java 有一定了解
            3. 熟悉 MFC ,能夠熟練使用 VC ,懂e-VC
            4. 熟悉TCP/IP、HTTP,了解各種互聯網應用(如browser,email,IM);

            手機銷售總監及經理(海外市場)
            工作職責:
            1.銷售體系完善,銷售策略優化。 2.銷售團隊管理,提升銷售業績。
            具體要求如下:
            1.五年以上手機海外銷售相關經驗,銷售區域最好在東南亞,中東,非洲地區或其他發展中國家。
            2.三年以上高級銷售經理或總監管理經驗
            3. 英語流利溝通,或會法語或日語或其他外語的優先。

            手機銷售總監及經理(國內市場):
            1.熟悉國內手機市場,銷售模式及分銷渠道
            2.有一定的客戶資源及代理商、分銷售商資源
            3.有銷售戰略意識,優秀的戰術管理能力及團隊領導能力

            射頻方向(6人 RF/RFID)
            1 本科以上學歷,電子或通信專業;
            2 熟悉MSP430單片機,能獨立負責項目研發工作;
            3 熟悉和精通 cc1100 cc2500 cc1101等TI CHIPCON產品優先;
            4 熟悉精通無線傳感器網絡,低速率低功耗無線個域網;
            5 熟練精通C/C++程序設計,有多年軟件開發經驗者優先;
            6 熟悉有源RFID,無源RFID者優先;
            7 有豐富射頻開發經驗者優先考慮。

            職位要求: 射頻方向(6人 RF/RFID)
            1 本科以上學歷,電子或通信專業;
            2 熟悉MSP430單片機,能獨立負責項目研發工作;
            3 熟悉和精通 cc1100 cc2500 cc1101等TI CHIPCON產品優先;
            4 熟悉精通無線傳感器網絡,低速率低功耗無線個域網;
            5 熟練精通C/C++程序設計,有多年軟件開發經驗者優先;
            6 熟悉有源RFID,無源RFID者優先;
            7 有豐富射頻開發經驗者優先考慮。

            基帶工程師
            職位描述: 主要工作職責:
            1、主要從事基帶硬件電路設計、硬件調試、故障分析定位、客戶硬件支持等工作;
            2、從事音頻調試工作;
            3、從事物料評估、選型、認證等工作;
            4、負責項目試產的技術支持,生產過程中硬件相關問題的現場解決。
            職位要求: 任職要求:
            1、學歷:本科或以上學歷;
            2、專業:通訊、電子工程、計算機等相關專業;
            3、工作經歷:2年硬件開發工作經驗,有3G開發經驗者優先;
            4、其他:項目涉及異地開發,需有良好的溝通能力,能適應出差,良好的英文讀寫能力。


            備注: 本公司是專做手機行業的獵頭公司,現為中國區域內多家知名手機企業招聘多名手機銷售管理人才,根據資歷定年薪,待遇優厚,上不封頂,工作地點根據候選人意向可協商(不限于深圳,上海,北京,廣州,其他地區也有我公司客戶需求)歡迎手機行業各類高級人才朋友聯系我們(加QQ、MSN、手機),通過人才自薦或有獎推薦他人成為您職業生涯中的朋友。本招聘信息長期有效,聯系人:king
            聯系電話:15889433717 QQ:877211649(手機行業) MSN:yclhr@yclhr.com
              回復  更多評論
              
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(4)

            隨筆檔案

            文章分類

            文章檔案

            相冊

            好友博客

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久免费看黄a级毛片| 久久久久人妻一区精品果冻| 亚洲中文久久精品无码| 国产成人精品白浆久久69 | 国产国产成人久久精品| 久久精品国产一区二区电影| 久久久精品人妻一区二区三区蜜桃| 亚洲国产欧美国产综合久久| 99热热久久这里只有精品68| 久久久久久曰本AV免费免费| 欧美777精品久久久久网| 亚洲欧洲久久av| 久久综合丁香激情久久| 无码精品久久久久久人妻中字| 久久高清一级毛片| 99久久精品影院老鸭窝| 无码国内精品久久综合88| 国产精品美女久久久久av爽| 久久久久久毛片免费播放| 国产精品一区二区久久精品涩爱| 91精品婷婷国产综合久久| 久久久久久久久无码精品亚洲日韩| 亚洲综合久久夜AV | 狠狠人妻久久久久久综合| 久久久青草久久久青草| 久久99国内精品自在现线| 精品熟女少妇AV免费久久| 要久久爱在线免费观看| 欧美精品丝袜久久久中文字幕 | 久久无码av三级| 久久国产亚洲精品无码| 狼狼综合久久久久综合网| 国内精品久久国产| 久久免费看黄a级毛片| 久久亚洲AV无码精品色午夜| 午夜精品久久久久久久无码| 国产一区二区精品久久凹凸| 久久精品国产福利国产琪琪| 久久无码AV中文出轨人妻| 婷婷国产天堂久久综合五月| 综合久久精品色|