青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

qiezi的學習園地

AS/C/C++/D/Java/JS/Python/Ruby

  C++博客 :: 首頁 :: 新隨筆 ::  ::  :: 管理 ::
標題:Proposal: Operator overloading without temporaries
作者:Don Clugston <dac@nospam.com.au>

正文:
Background: Operator overloading, in the form it exists in C++ and
currently in D, inherently results in sub-optimal code, because it
always results in unnecessary temporary objects being created.

For example,
X = A - ((B*C) + D)* E;

becomes:
T1 = B * C;
T2 = T1 + D;
T3 = T2 * E;
T4 = A - T3;
X = T4;
Four objects were created, whereas only one was strictly required.
In C++, there are libraries like Blitz++ which use complicated
expression templates in order to avoid these creating these temporaries,
and provide performance comparable with FORTRAN. I think D can do much
better...
Note that temporaries are avoided when using the opXXXAssign() operators
like +=.

===========
?? Proposal
===========
(1) Allow the compiler to assume that b = b + c? can be replaced with b
+= c. (In C++, operator + and operator += are just symbols, the compiler
doesn't know that there is any relationship between them).
In the example above, this would allow the compiler to generate:
T1 = B * C;
T1 += D;
T1 *= E;

and we have eliminated two of the three temporaries.
(2). Fill in the gaps in the operator overloading table by introducing
opAddAssign_r, opSubAssign_r, etc.

Just as A.opSubAssign(B)
is the operation? A -= B? or equivalently? A = A - B, similarly

A.opSubAssign_r(B)
would mean
A = B - A.
and would only occur when temporaries are generated in expressions. Like
-=, it's an operation which can frequently be performed very
efficiently, but at present the language has no way of expressing it.

Our original example then becomes:

T1 = B.opMul(C);
T1.opAddAssign(D);
T1.opMulAssign(E);
T1.opSubAssign_r(A);
X = T1;
... and all the useless temporaries are gone!

More formally, when the expression tree for an expression is generated:
With a binary operator XXX, operating on left & right nodes:

if (the left node is *not* an original leaf node) {
??? // the left node is a temporary, does not need to be preserved.
??? // we don't care if the right node is a temporary or not
??? look for opXXXAssign().
} else if (the the right node is not an original leaf node) {
??? // the right node is a temporary
??? look for opXXXAssign_r()
} else {
?? // both left and right nodes are leaf nodes, we have to
?? // create a temporary
??? look for opXXX(), just as it does now.
}

These rules also cope with the situation where temporaries are required:
eg
X = (A*B) + (C*D);
becomes
T1 = A*B;
T2 = C*D;
T1 += T2;
X = T1;

If this were implemented, it would permanently eradicate (for D) the
most significant advantage which Fortran has managed to retain over
object-oriented languages. And I really don't think it would be
difficult to implement, or have negative side-effects.

There are a couple of decisions to be made:
(I) should the compiler use opAdd() and generate a temporary, if
opAddAssign_r() doesn't exist, to preserve existing behaviour? I think
the answer to this is YES.
(II) should the compiler use opAdd() and generate a temporary, if
oppAddAssign() doesn't exist, to preserve existing behaviour? Again, I'm
inclined to answer YES.
(III) If the code includes +=, and there is an opAdd() but no
opAddAssign(), should the compiler accept this, and just generate an
opAdd() followed by an assignment?? This would mean that opAdd() would
generate the += operation as well as +, while opAddAssign() would be a
performance enhancement. (It would still be possible to have
opAddAssign() without opAdd(), to have += but not +, but it would not be
possible to have + without +=). This would mean that += would be
*purely* syntactic sugar.

Decision III would be a little more difficult to implement and is of
less obvious merit, I only mention it as a possibility.

Comments?
posted on 2006-03-28 10:31 qiezi 閱讀(553) 評論(0)  編輯 收藏 引用 所屬分類: D
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            91久久午夜| 99ri日韩精品视频| 久热精品视频在线免费观看| 久久精品国产精品 | 国产精品欧美日韩一区二区| 欧美日韩中国免费专区在线看| 欧美日韩国产a| 国产精品国产馆在线真实露脸| 国产精品影音先锋| 好吊色欧美一区二区三区四区| 亚洲大胆女人| aa国产精品| 久久精品国产精品亚洲| 另类尿喷潮videofree| 亚洲国产成人精品女人久久久| 日韩午夜在线播放| 亚洲综合精品一区二区| 亚洲国产91| 一区二区三区久久| 性久久久久久久久| 欧美成人在线免费视频| 亚洲毛片在线观看.| 性做久久久久久久久| 美女性感视频久久久| 欧美午夜www高清视频| 狠狠爱成人网| 亚洲欧美怡红院| 亚洲国产精品成人精品| 欧美一级淫片aaaaaaa视频| 欧美成人午夜激情在线| 国产欧美短视频| av成人福利| 久久免费偷拍视频| 亚洲少妇在线| 欧美日韩国产不卡在线看| 黑人巨大精品欧美一区二区小视频| 亚洲精品久久7777| 麻豆成人在线| 欧美一区中文字幕| 国产精品入口福利| 欧美韩日一区二区| 国产日产欧美精品| 亚洲欧美另类久久久精品2019| 欧美激情一区二区三区成人| 欧美在线亚洲在线| 国产亚洲综合在线| 久久国产精品久久久久久久久久| 99热在这里有精品免费| 欧美大片在线影院| 亚洲国产视频直播| 久久夜色撩人精品| 久久九九国产精品怡红院| 国产日韩在线看| 亚洲欧美日韩国产一区二区| 日韩午夜中文字幕| 欧美日韩国产成人在线免费| 欧美交受高潮1| 亚洲国产日韩欧美| 欧美1区3d| 蜜桃久久精品一区二区| 亚洲国产精品99久久久久久久久| 久久久久久色| 久久精品99无色码中文字幕| 国产日韩精品一区二区浪潮av| 亚洲综合色视频| 这里只有精品视频| 国产精品一区二区三区久久| 欧美一区二区高清在线观看| 午夜精品一区二区三区在线| 国产亚洲欧美日韩在线一区| 久久裸体视频| 免费成人高清| 一本久久综合亚洲鲁鲁五月天| 亚洲精品久久久一区二区三区| 欧美wwwwww| 亚洲视频精选在线| 国产人成一区二区三区影院| 欧美成人日韩| 欧美片第一页| 亚洲综合视频1区| 亚洲欧美在线免费| 国产亚洲亚洲| 亚洲国产一区二区精品专区| 欧美经典一区二区| 香蕉av777xxx色综合一区| 欧美一区二区日韩一区二区| 亚洲成人在线网| 一本色道久久综合亚洲精品按摩 | 久久免费视频一区| 亚洲裸体俱乐部裸体舞表演av| 日韩一级不卡| 国产欧美日韩精品专区| 欧美成人午夜77777| 欧美久久久久久久| 久久精品国产99国产精品| 久久精品国产视频| 中国av一区| 久久久久国内| 国产伦一区二区三区色一情| 欧美激情国产精品| 国产精品福利在线观看| 欧美aaaaaaaa牛牛影院| 国产精品国产一区二区| 欧美激情国产日韩精品一区18| 国产精品电影观看| 亚洲高清视频一区| 韩日在线一区| 亚洲国产成人精品视频| 国内精品久久久久久久97牛牛| 亚洲电影一级黄| 一区在线电影| 亚洲天堂av综合网| 99ri日韩精品视频| 久久夜色精品国产亚洲aⅴ| 午夜精品久久久久久99热软件| 免费观看成人鲁鲁鲁鲁鲁视频| 久久高清一区| 国产精品国产福利国产秒拍 | 午夜精品在线观看| 欧美激情久久久久久| 免费看精品久久片| 国产日韩精品一区二区三区在线| 亚洲精品乱码久久久久久久久| 精品成人一区| 欧美一级久久| 欧美影片第一页| 国产精品国产| 一区二区三区黄色| 中文av字幕一区| 欧美成人高清视频| 欧美激情欧美狂野欧美精品 | 精品av久久久久电影| 午夜精品影院| 午夜精品久久久| 久久综合久久综合久久| 亚洲国产福利在线| 欧美影片第一页| 久久精品噜噜噜成人av农村| 国产老肥熟一区二区三区| 亚洲主播在线播放| 性色一区二区| 国产在线观看精品一区二区三区| 亚洲欧美日韩电影| 久久久人成影片一区二区三区| 国产欧美午夜| 久久精品亚洲一区| 欧美h视频在线| 亚洲免费观看在线视频| 欧美日韩国产综合新一区| 99这里只有精品| 亚洲免费在线电影| 国产精品美女久久| 性欧美videos另类喷潮| 久久精品中文| 亚洲国产精品电影| 欧美精品三级日韩久久| 一本色道久久综合亚洲精品小说| 国产精品99久久久久久久久| 国产精品无码永久免费888| 欧美亚洲免费| 欧美jjzz| 亚洲免费视频观看| 激情亚洲网站| 欧美区在线播放| 亚洲专区一区| 亚洲福利视频一区| 亚洲在线一区| 1024成人| 国产精品成人免费| 久久久久在线| 亚洲精品久久久久久一区二区| 午夜在线视频一区二区区别| 国内综合精品午夜久久资源| 欧美激情在线| 亚洲综合99| 亚洲精品国产精品国自产在线| 亚洲一区二区三区成人在线视频精品 | 中文国产一区| 久久综合99re88久久爱| 一区二区三区导航| 国产又爽又黄的激情精品视频| 欧美日韩国产经典色站一区二区三区| 亚洲无线视频| 欧美激情一区二区| 欧美一区二区在线| 亚洲毛片在线免费观看| 国产日韩欧美麻豆| 欧美日韩性视频在线| 欧美在线免费看| 亚洲视频欧美视频| 亚洲精品123区| 久久亚洲精品一区| 午夜精品久久久久久久| 99视频超级精品| 一区二区在线观看视频在线观看| 欧美午夜寂寞影院| 欧美黑人多人双交| 久久免费少妇高潮久久精品99| 羞羞视频在线观看欧美| 一区二区三区视频在线观看|