.step one Standard
An agent was a part that represent this is off an enthusiastic term agent which can be applied to instances of the course. Workers are proclaimed playing with user_declarations:
6.1) otherwise a phrase looks (§14.6.1). A beneficial block human anatomy include an excellent block, which determine the fresh wskazówki dotyczÄ…ce meddle statements to execute if the user was invoked. The fresh new block will comply with the rules to possess really worth-coming back steps described within the §fourteen.six.eleven. An expression system consists of => followed by an expression and a good semicolon, and indicates just one expression to execute if agent are invoked.
To possess extern workers, this new operator_system is made up simply from a semicolon. For everyone almost every other providers, the fresh new driver_person is both a block system otherwise a term looks.
- An user declaration shall include one another a public and you may a fixed modifier.
- The latest factor(s) out-of an user should do not have modifiers.
- The latest trademark off a driver (§.dos, §.step 3, §.4) shall differ from the signatures of all the other providers age category.
- Every type referenced within the an agent report can be at the very least while the obtainable as the agent in itself (§7.5.5).
- It’s a mistake for the very same modifier to appear several minutes from inside the an operator statement.
Like other players, workers stated in the a bottom group try inherited because of the derived categories. While the driver declarations usually require class or struct where the new operator is actually announced to sign up the fresh new trademark of your own operator, this is not possible for a driver proclaimed for the an effective derived category to cover up an operator announced inside a base class. Therefore, new modifier is never required, and that never enabled, for the an operator declaration.
.dos Unary providers
Next laws connect with unary operator declarations, in which T denotes this new including sort of the course otherwise struct which includes the fresh new agent declaration:
, ++ , — , real , or not the case ) in addition to version of the latest solitary specialized factor. The fresh return sort of isn’t section of good unary operator’s trademark, nor ‘s the term of your own certified parameter.
The genuine and you will incorrect unary workers want couple-wise statement. A collect-time mistake happen when the a class declares one among these workers in the place of as well as claiming the other. The genuine and you will false operators try revealed after that inside §.
Note how the driver means returns the significance produced by including step 1 to your operand, as postfix increment and you can decrement providers (§eleven.7.14), in addition to prefix increment and you may decrement operators (§eleven.8.6). Rather than for the C++, this method shouldn’t customize the worth of their operand personally that manage break the product quality semantics of the postfix increment user (§11.eight.14). avoid example
.step 3 Digital providers
The second legislation connect with digital agent declarations, where T indicates the latest such as for example brand of the category or struct which has the latest user report:
- A digital non-shift agent will simply take one or two variables, one or more at which shall has actually type T or T? , and will come back all kinds.
- 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 binary operators require partners-smart declaration. Each declaration out of sometimes operator away from a pair, indeed there would be a matching report of your own almost every other operator from the two. A couple of agent declarations fits in the event the identity conversion rates can be found ranging from the return items and their related factor models. The next workers wanted few-smart report: