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

             

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

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

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


            對(duì)于Stephan T. Lavavej寫的

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

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

            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 提到:"任何一個(gè)表達(dá)式,不是左值,就是右值",左值或者右值是針對(duì)表達(dá)式而言的,object沒有左右值之分,應(yīng)該時(shí)刻謹(jǐn)記這一點(diǎn)。

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

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

             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的標(biāo)準(zhǔn),然而這對(duì)move語義和完美轉(zhuǎn)發(fā)的實(shí)習(xí),確實(shí)是一種障礙。關(guān)于move語義和完美轉(zhuǎn)發(fā),請(qǐng)看《C++0x漫談》系列之:右值引用 或“move語意與完美轉(zhuǎn)發(fā)”(上)《C++0x漫談》系列之:右值引用 或“move語意與完美轉(zhuǎn)發(fā)”(下)

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

            下面是關(guān)于函數(shù)左右值的重載決議:
            1 .  The initialization rules have veto power.

            初始化規(guī)則具有否決權(quán)(否決權(quán)指對(duì)所有候選函數(shù),如果有參數(shù)根本不能轉(zhuǎn)化,就放棄考慮,比如把一個(gè)const type轉(zhuǎn)化為type)。

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

            左值優(yōu)先綁定左值,右值優(yōu)先綁定右值。

            3 .  Modifiable expressions weakly prefer binding to modifiable references.

            非const表達(dá)式趨向于綁定非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&& :

            在實(shí)踐中,重載所有的4個(gè)版本沒有意義,而我們更傾向于使用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.

            對(duì)于 purr(up) ,決議(1)沒有否決 purr(const string&) 和 purr(string&&) ,up是左值,所以依照決議(2),它優(yōu)先綁定左值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.

            對(duì)于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.

             對(duì)于purr(strange()),決議(1)都沒有否決,strange() 是右值,所以依照決議(2),優(yōu)先綁定右值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.

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

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

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

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

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

            手機(jī)銷售總監(jiān)及經(jīng)理(海外市場)
            工作職責(zé):
            1.銷售體系完善,銷售策略優(yōu)化。 2.銷售團(tuán)隊(duì)管理,提升銷售業(yè)績。
            具體要求如下:
            1.五年以上手機(jī)海外銷售相關(guān)經(jīng)驗(yàn),銷售區(qū)域最好在東南亞,中東,非洲地區(qū)或其他發(fā)展中國家。
            2.三年以上高級(jí)銷售經(jīng)理或總監(jiān)管理經(jīng)驗(yàn)
            3. 英語流利溝通,或會(huì)法語或日語或其他外語的優(yōu)先。

            手機(jī)銷售總監(jiān)及經(jīng)理(國內(nèi)市場):
            1.熟悉國內(nèi)手機(jī)市場,銷售模式及分銷渠道
            2.有一定的客戶資源及代理商、分銷售商資源
            3.有銷售戰(zhàn)略意識(shí),優(yōu)秀的戰(zhàn)術(shù)管理能力及團(tuán)隊(duì)領(lǐng)導(dǎo)能力

            射頻方向(6人 RF/RFID)
            1 本科以上學(xué)歷,電子或通信專業(yè);
            2 熟悉MSP430單片機(jī),能獨(dú)立負(fù)責(zé)項(xiàng)目研發(fā)工作;
            3 熟悉和精通 cc1100 cc2500 cc1101等TI CHIPCON產(chǎn)品優(yōu)先;
            4 熟悉精通無線傳感器網(wǎng)絡(luò),低速率低功耗無線個(gè)域網(wǎng);
            5 熟練精通C/C++程序設(shè)計(jì),有多年軟件開發(fā)經(jīng)驗(yàn)者優(yōu)先;
            6 熟悉有源RFID,無源RFID者優(yōu)先;
            7 有豐富射頻開發(fā)經(jīng)驗(yàn)者優(yōu)先考慮。

            職位要求: 射頻方向(6人 RF/RFID)
            1 本科以上學(xué)歷,電子或通信專業(yè);
            2 熟悉MSP430單片機(jī),能獨(dú)立負(fù)責(zé)項(xiàng)目研發(fā)工作;
            3 熟悉和精通 cc1100 cc2500 cc1101等TI CHIPCON產(chǎn)品優(yōu)先;
            4 熟悉精通無線傳感器網(wǎng)絡(luò),低速率低功耗無線個(gè)域網(wǎng);
            5 熟練精通C/C++程序設(shè)計(jì),有多年軟件開發(fā)經(jīng)驗(yàn)者優(yōu)先;
            6 熟悉有源RFID,無源RFID者優(yōu)先;
            7 有豐富射頻開發(fā)經(jīng)驗(yàn)者優(yōu)先考慮。

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


            備注: 本公司是專做手機(jī)行業(yè)的獵頭公司,現(xiàn)為中國區(qū)域內(nèi)多家知名手機(jī)企業(yè)招聘多名手機(jī)銷售管理人才,根據(jù)資歷定年薪,待遇優(yōu)厚,上不封頂,工作地點(diǎn)根據(jù)候選人意向可協(xié)商(不限于深圳,上海,北京,廣州,其他地區(qū)也有我公司客戶需求)歡迎手機(jī)行業(yè)各類高級(jí)人才朋友聯(lián)系我們(加QQ、MSN、手機(jī)),通過人才自薦或有獎(jiǎng)推薦他人成為您職業(yè)生涯中的朋友。本招聘信息長期有效,聯(lián)系人:king
            聯(lián)系電話:15889433717 QQ:877211649(手機(jī)行業(yè)) MSN:yclhr@yclhr.com
              回復(fù)  更多評(píng)論
              

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            <2009年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(4)

            隨筆檔案

            文章分類

            文章檔案

            相冊(cè)

            好友博客

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            成人久久精品一区二区三区 | 亚洲精品成人久久久| 久久黄视频| 日本加勒比久久精品| 国产成人无码久久久精品一| 精品国产一区二区三区久久蜜臀| 久久婷婷国产剧情内射白浆| 久久国产热精品波多野结衣AV| 亚洲国产成人久久综合碰碰动漫3d| 久久久久一本毛久久久| 久久精品国产亚洲AV大全| 青青草原综合久久大伊人精品| 99久久国产宗和精品1上映 | 91久久九九无码成人网站| 精品久久久久久无码免费| 2019久久久高清456| 久久99国产一区二区三区| 久久久久波多野结衣高潮| 狠狠干狠狠久久| 久久精品中文字幕一区| 国产Av激情久久无码天堂| 久久久久黑人强伦姧人妻| 国内精品久久久久影院一蜜桃| 久久久久亚洲AV成人网人人网站| 99久久国产宗和精品1上映 | 伊人丁香狠狠色综合久久| 2021久久精品免费观看| 久久这里只精品国产99热| 久久精品国产男包| 久久精品人妻一区二区三区| 东京热TOKYO综合久久精品| 久久精品综合网| 久久免费99精品国产自在现线| 18岁日韩内射颜射午夜久久成人| 精品久久久久中文字幕一区| 久久久久99精品成人片试看| 亚洲伊人久久成综合人影院 | 久久91精品综合国产首页| 久久精品国产亚洲av日韩| 亚洲天堂久久久| 久久一本综合|