.step one Standard
An operator try an associate one defines the definition of a keen phrase driver that is certainly put on instances of the course. Workers are announced having fun with agent_declarations:
six.1) otherwise an expression body (§fourteen.six.1). An excellent take off human anatomy contains an excellent stop, and this specifies the brand new statements to execute if operator are invoked. The new stop shall follow the guidelines to possess value-coming back strategies discussed inside §14.6.11. A phrase system includes => accompanied by a phrase and a good semicolon, and indicates an individual term to perform in the event the operator is invoked.
Having extern operators, the new agent_looks is made up simply off an excellent semicolon. For all other providers, new user_person is either a great cut off human body otherwise an expression human anatomy.
- An operator statement will become each other a general public and you will a static modifier.
- The new parameter(s) out of an agent should have no modifiers.
- The newest trademark of a driver (§.2, §.step three, §.4) should change from the brand new signatures of all of the other workers e class.
- Every type referenced within the an user declaration is going to be at the very least as the accessible once the user in itself (§eight.5.5).
- It’s a blunder for the very same modifier to seem several moments when you look at the an agent report.
Like many participants, workers proclaimed inside the a bottom classification was passed down because of the derived groups. Because user declarations usually need to have the class otherwise struct where the brand new operator is actually proclaimed to sign up the latest trademark of one’s user, that isn’t possible for a driver declared when you look at the a beneficial derived classification to hide an agent proclaimed during the a base classification. Thus, brand new modifier has never been necessary, and therefore never ever permitted, inside the an user report.
.dos Unary operators
The second laws and regulations connect with unary driver declarations, in which T denotes the brand new such as for example form of the course or struct who has the newest agent declaration:
, ++ , — , real , or incorrect ) and type of the newest unmarried certified parameter. Brand new return particular isn’t part of good unary operator’s trademark, nor is the name of your certified parameter.
The genuine and you may untrue unary providers need pair-wise report. An amass-day error takes place if the a class announces one of these workers versus along with declaring the other. The actual and not the case workers was revealed further from inside the §.
Mention how the agent strategy efficiency the significance produced by incorporating 1 on the operand, because the postfix increment and you can decrement providers (§11.eight.14), therefore the prefix increment and you can decrement workers (§11.8.6). Unlike from inside the C++, this technique shouldn’t customize the value of the operand privately because create break the standard semantics of your own postfix increment driver (§eleven.7.14). stop example
.step three Digital workers
Another regulations affect digital operator declarations, in which T indicates brand new eg particular the category otherwise struct that has the fresh new user statement:
- A digital non-change agent should bring a few parameters, one where shall have method of T otherwise T? , and certainly will come back any kind.
- A binary << or >> operator (§) shall take two parameters, the first of which shall have type T or T? and the second of which shall have type int or int? , and can return any type. The signature of a binary operator consists of the operator token ( + , – , * , / , % , , | , ^ , << , >> , == , != , > , < , >= , or <= ) and the types of the two formal parameters. The return type and the names of the formal parameters are not part of a binary operator's signature.
Certain digital operators want couples-wise report. For every declaration regarding sometimes user away from moobs, indeed there will be a matching statement of the most other agent out-of the pair. Two operator declarations suits if term conversions exists anywhere between the return designs and their involved factor items. The https://datingranking.net/pl/livejasmin-recenzja/ next workers require couple-wise declaration: