Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the C++ operator ->. (arrow dot operator) found in boost documentation?

I'm reading boost documentation and see the following at http://www.boost.org/doc/libs/1_54_0/doc/html/lambda/le_in_details.html :

Operators that cannot be overloaded

Some operators cannot be overloaded at all (::, ., .*). For some operators, the requirements on return types prevent them to be overloaded to create lambda functors. These operators are ->., ->, new, new[], delete, delete[] and ?: (the conditional operator).

So what is the operator ->. ? I tried Google and http://www.symbolhound.com/ but didn't get anything useful, searching on N3337 gives 1 result that is -> at the end of a sentence, and Visual Studio 2012 won't compile:

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

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

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

I believe the author intentionally wrote ->. since -> and . is also included, but what is ->., or why it is here?

like image 413
jingyu9575 Avatar asked Sep 20 '13 08:09

jingyu9575


People also ask

What is the -> operator in C++?

The -> is called the arrow operator. It is formed by using the minus sign followed by a greater than sign. Simply saying: To access members of a structure, use the dot operator. To access members of a structure through a pointer, use the arrow operator.

What is arrow operator?

The -> (arrow) operator is used to access class, structure or union members using a pointer. A postfix expression, followed by an -> (arrow) operator, followed by a possibly qualified identifier or a pseudo-destructor name, designates a member of the object to which the pointer points.

What is the difference between dot operator and arrow operator in C?

Difference between Dot(.)operator is used to normally access members of a structure or union. The Arrow(->) operator exists to access the members of the structure or the unions using pointers.


2 Answers

IT seems to be a typo.

In the C++ draft 3690, there is no mention about an operator ->..

It could be the ->*:

5.5 Pointer-to-member operators [expr.mptr.oper]

The pointer-to-member operators ->* and .* group left-to-right.

And in http://www.boost.org/doc/libs/1_54_0/doc/html/lambda/le_in_details.html, they have some example with this operator.

like image 65
Pierre Fourgeaud Avatar answered Sep 23 '22 05:09

Pierre Fourgeaud


As you can see from C++11, 2.13: "Operators and punctuators", there is no such operator as "->.".

like image 35
Kerrek SB Avatar answered Sep 19 '22 05:09

Kerrek SB