【问题标题】:What is the C++ operator ->. (arrow dot operator) found in boost documentation?什么是 C++ 运算符 ->。 (箭头点运算符)在 boost 文档中找到?
【发布时间】:2013-09-20 08:15:05
【问题描述】:

我正在阅读 boost 文档并在 http://www.boost.org/doc/libs/1_54_0/doc/html/lambda/le_in_details.html 看到以下内容:

不能重载的运算符

有些运算符根本不能重载(::, ., .*)。对于一些 运算符,对返回类型的要求阻止它们 重载以创建 lambda 仿函数。 这些运算符是 ->.、->、 new、new[]、delete、delete[] 和 ?:(条件运算符)。

那么->. 运算符是什么?我尝试了 Google 和 http://www.symbolhound.com/,但没有得到任何有用的信息,在 N3337 上搜索会得到 1 个结果,即句尾为 ->,而 Visual Studio 2012 将无法编译:

class xT {
    bool operator ->. () {} /* fail */
};

std::string* p;
p->.size(); /* fail */

std::auto_ptr<std::string> a;
a->.size(); /* fail */

我相信作者故意写了-&gt;.,因为-&gt;.也包括在内,但是-&gt;.是什么,或者为什么会出现在这里?

【问题讨论】:

标签: c++ boost operator-keyword


【解决方案1】:

它似乎是一个错字。

在 C++ 草案 3690 中,没有提及运算符 -&gt;.

可能是-&gt;*

5.5 指向成员运算符 [expr.mptr.oper]

成员指针运算符-&gt;*.* 从左到右分组。

http://www.boost.org/doc/libs/1_54_0/doc/html/lambda/le_in_details.html 中,他们有一些关于此运算符的示例。

【讨论】:

  • 嗯....* 也在这里,但我没想到...我的脑海里充满了一些调用用户定义的operator -&gt; 并从非指针结果
【解决方案2】:

从 C++11, 2.13 中可以看出:“运算符和标点符号”,没有“-&gt;.”这样的运算符。

【讨论】:

    【解决方案3】:

    没有像“->”这样的运算符。 http://msdn.microsoft.com/en-us/library/x04xhy0h.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-19
      • 2013-07-16
      • 2017-12-08
      • 2012-12-04
      • 2010-12-07
      • 2014-01-30
      • 1970-01-01
      • 2012-10-12
      相关资源
      最近更新 更多