The brand new driver_body is either an excellent semicolon, a beneficial block human body (§fourteen

The brand new driver_body is either an excellent semicolon, a beneficial block human body (§fourteen

.step one Standard

An agent was an associate one describes the definition off an enthusiastic term operator which is often used on instances of the course. Operators is actually declared playing with driver_declarations:

6.1) or a term human body (§14.six.1). A good take off looks consists of a beneficial cut-off, and this determine this new statements to perform if driver was invoked. The new stop should conform to waplog the guidelines having well worth-returning procedures explained in §fourteen.6.eleven. A term looks contains => with a term and you may a beneficial semicolon, and you may denotes just one term to do in the event that operator try invoked.

To possess extern operators, this new agent_human body is made up only of a good semicolon. For everyone other operators, brand new agent_person is often a great block human anatomy otherwise a term muscles.

  • A driver declaration should are one another a public and a static modifier.
  • New factor(s) of a driver should have no modifiers.
  • The new signature regarding an user (§.dos, §.step 3, §.4) will range from the fresh new signatures of all of the almost every other providers elizabeth group.
  • All sorts referenced into the an user declaration are going to be at the very least since obtainable due to the fact agent in itself (§eight.5.5).
  • It is a blunder for similar modifier to appear numerous moments during the an agent report.

Like many users, operators declared when you look at the a bottom category is passed on by the derived categories. Since operator declarations constantly need to have the category otherwise struct where the brand new driver was announced to sign up the trademark of the agent, it is not possible for a driver announced from inside the an excellent derived group to hide an user proclaimed for the a base class. Therefore, brand new modifier is never needed, and that never permitted, within the a driver report.

.2 Unary operators

The following rules apply at unary agent declarations, where T denotes the fresh new like brand of the class or struct that features the fresh operator statement:

, ++ , — , real , or not true ) and also the sort of new solitary authoritative parameter. The newest return variety of isn’t part of an excellent unary operator’s signature, neither is the identity of the certified factor.

The true and you may incorrect unary operators need pair-smart declaration. A harvest-big date mistake takes place if the a course declares one of those providers as opposed to together with claiming others. The true and you can incorrect operators is actually revealed further during the §.

Mention the driver strategy output the importance developed by including step 1 with the operand, due to the fact postfix increment and you will decrement providers (§11.seven.14), in addition to prefix increment and you will decrement operators (§eleven.8.6). In lieu of during the C++, this process shouldn’t modify the worth of its operand physically because this do break the high quality semantics of your own postfix increment operator (§eleven.eight.14). stop analogy

.step three Digital workers

The next statutes affect digital user declarations, where T denotes this new eg particular the course or struct containing the brand new operator declaration:

  • A binary low-shift agent will bring a few parameters, one or more from which shall enjoys sorts of T or T? , and can get back any sort.
  • 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.

Particular digital providers wanted few-smart declaration. Per statement away from both operator regarding a pair, around will be a matching report of most other agent of the two. A couple of operator declarations fits if the title sales exists ranging from its get back designs as well as their involved factor sizes. Next providers wanted partners-smart report: