可以用C ++ 0X实现ptr->()和ptr-> []吗? [英] could ptr->() and ptr->[] be implemented in C++0X?

查看:48
本文介绍了可以用C ++ 0X实现ptr->()和ptr-> []吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现像(* ptr)(arg)和(* ptr)[i]这样的东西,至少是尴尬的
。我经常认为以下内容对于ptr->运算符(arg),ptr-> operator [i]的替代形式是有用的:


ptr->(arg)

ptr-> [i]


有些人可能会发现这样的表达难以理解。如果可以让它工作,那么我相信它很快就会被学习,并且很可能被一个好的

的程序员使用。有没有人知道纯粹的技术原因,如果它被添加到标准中,则无法实现
功能?

-

如果我们的假设是关于任何事情而不是关于某一个或多个特定事物,那么我们的推论就构成了数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题.- Bertrand Russell

I find writing things such as (*ptr)(arg), and (*ptr)[i], to be at least
awkward. I''ve often thought the following would be useful as an
alternative form of ptr->operator(arg), ptr->operator[i]:

ptr->(arg)
ptr->[i]

Some people may find such an expression unintelligible. If it could be made
to work, I believe it would be quickly learned, and probably used by a good
number of programmers. Does anybody know of a purely technical reason that
functionality couldn''t be implemented if it were added to the standard?
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell

推荐答案

" Steven T. Hatton" < CH ******** @ germania.sup>在消息中写道

新闻:Ps ******************** @ speakeasy.net ...
"Steven T. Hatton" <ch********@germania.sup> wrote in message
news:Ps********************@speakeasy.net...
我找到像(* ptr)(arg)和(* ptr)[i]这样的东西,至少是尴尬的。我经常认为以下内容可用作ptr->运算符(arg)的另一种形式,ptr-> operator [i]:

ptr-> (arg)
ptr-> [i]

有些人可能会发现这样的表达难以理解。如果它可以工作,我相信它会很快学会,并且很可能被一些好的程序员使用。有没有人知道纯粹的技术原因
如果它被添加到标准中就无法实现?
I find writing things such as (*ptr)(arg), and (*ptr)[i], to be at least
awkward. I''ve often thought the following would be useful as an
alternative form of ptr->operator(arg), ptr->operator[i]:

ptr->(arg)
ptr->[i]

Some people may find such an expression unintelligible. If it could be
made
to work, I believe it would be quickly learned, and probably used by a
good
number of programmers. Does anybody know of a purely technical reason
that
functionality couldn''t be implemented if it were added to the standard?




部分关注 - >应该是根据语法

规则的标识符。因此,通过允许这种语法,语法规则必须被重写为
。我认为这是一个比人们愿意支付更高的成本

一些特别难看的语法糖:)

-

问候,


Ferdi Smit

smit xs4all nl



The part following the -> should be an identifier according to the grammar
rules. So by allowing this syntax, the grammar rules would have to be
rewritten. I think that''s a cost higher than people are willing to pay for
some exceptionally ugly syntactic sugar :)
--
Regards,

Ferdi Smit
smit xs4all nl


Ferdi Smit写道:
Ferdi Smit wrote:
" Steven T. Hatton" < CH ******** @ germania.sup>在消息中写道
新闻:Ps ******************** @ speakeasy.net ...
"Steven T. Hatton" <ch********@germania.sup> wrote in message
news:Ps********************@speakeasy.net...
我发现写的东西如此as(* ptr)(arg)和(* ptr)[i],至少是尴尬的。我经常认为以下内容可用作ptr->运算符(arg)的另一种形式,ptr-> operator [i]:

ptr-> (arg)
ptr-> [i]

有些人可能会发现这样的表达难以理解。如果它可以工作,我相信它会很快学会,并且很可能被一些好的程序员使用。有没有人知道纯粹的技术原因
如果它被添加到标准中就无法实现?
I find writing things such as (*ptr)(arg), and (*ptr)[i], to be at least
awkward. I''ve often thought the following would be useful as an
alternative form of ptr->operator(arg), ptr->operator[i]:

ptr->(arg)
ptr->[i]

Some people may find such an expression unintelligible. If it could be
made
to work, I believe it would be quickly learned, and probably used by a
good
number of programmers. Does anybody know of a purely technical reason
that
functionality couldn''t be implemented if it were added to the standard?



以下部分 - > ;应该是根据语法规则的标识符。因此,通过允许这种语法,必须重写语法规则。我认为这是一个比人们愿意支付的成本更高的
一些非常丑陋的语法糖:)



The part following the -> should be an identifier according to the grammar
rules. So by allowing this syntax, the grammar rules would have to be
rewritten. I think that''s a cost higher than people are willing to pay for
some exceptionally ugly syntactic sugar :)



我不相信语法将受到非常显着的影响。我的

自己的意见是ptr-> [i]比(* ptr)[i]更具可读性,而且我发现它更容易输入
好。 (* ptr)(arg)甚至比(* ptr)[i]更差。

另一种方法是创建对* ptr的引用,并使用pref(arg)和

pref [i]。如果您将大量使用该参考,这是合理的。

我甚至做过T& _self(*此)。另一个替代方案是ptr->运算符(arg)

和ptr-> operator [i],这似乎是冗长而冗余的。

-

如果我们的假设是关于任何事情而不是关于某一个或多个特定事物,那么我们的推论就构成了数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题.- Bertrand Russell


Steven T. Hatton写道:
Steven T. Hatton wrote:
[...]另一种选择是ptr-> operator(arg)


你的意思是


ptr-> operator()(arg)

和ptr-> operator [i]看起来很冗长和冗余。
[...] Another alternative is ptr->operator(arg)
You mean

ptr->operator()(arg)
and ptr->operator[i] which seems longwinded and redundant.




...和


ptr-> operator [](i)

>
您是否建议更换现有的表格以支持新表格或

只需添加新表格以补充现有表格?


我的问题是:什么,除了改变


(* ptr)(arg)





ptr->(arg)


你的建议是否提供?如果没有,你应该考虑花点时间在物质上。


V



...and

ptr->operator[](i)

Are you proposing to change those existing forms in favor of new ones or
simply add new ones to complement the already existing ones?

My question is this: what, except changing

(*ptr)(arg)

to

ptr->(arg)

does your suggestion provide? If nothing, you should consider spending
your time on something of substance.

V


这篇关于可以用C ++ 0X实现ptr-&gt;()和ptr-&gt; []吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆