.1 Standard
A driver try a member you to defines the meaning of an expression agent that can easily be put on instances of the course. Workers was declared playing with agent_declarations:
six.1) otherwise a term human anatomy (§14.6.1). A good stop muscles include a good cut-off, which determine this new comments to perform when the operator is invoked. Brand new take off will follow the principles for really worth-returning strategies demonstrated in the §fourteen.6.eleven. A term body consists of => with a phrase and you may a great semicolon, and you can indicates an individual expression to do in the event the driver try invoked.
To possess extern workers, the newest operator_body is made up merely from an effective semicolon. For everyone most other workers, new user_body’s often an excellent cut-off human body otherwise a phrase human anatomy.
- An agent report will include both a general public and you may a fixed modifier.
- The latest factor(s) out-of an user shall have no modifiers.
- New trademark out of a driver (§.2, §.3, §.4) should change from the fresh signatures of all other providers e group.
- All types referenced for the an operator report should be at the least since the obtainable due to the fact operator alone (§eight.5.5).
- It’s a mistake for similar modifier to look numerous minutes during the a driver statement.
Like other members, kod promocyjny match workers declared into the a bottom group are inherited because of the derived groups. As user declarations usually need the group or struct in which the user try declared to participate in brand new trademark of one’s user, this is not possible for an user announced when you look at the a derived classification to hide a driver stated into the a bottom class. Thus, new modifier has never been requisite, which never let, during the an agent declaration.
.2 Unary operators
Another rules apply at unary driver declarations, in which T indicates the brand new including kind of the course otherwise struct which has this new agent statement:
, ++ , — , real , or not the case ) while the sort of this new unmarried authoritative factor. The fresh new get back types of is not section of a unary operator’s trademark, nor is the label of one’s certified factor.
The true and not the case unary workers wanted pair-wise report. An assemble-day mistake happen if the a category announces one of them providers instead as well as declaring the other. The true and not the case operators try discussed next during the §.
Note how the operator strategy production the importance developed by adding step one on operand, while the postfix increment and you may decrement workers (§11.eight.14), therefore the prefix increment and you can decrement workers (§eleven.8.6). Unlike within the C++, this method should not modify the worth of the operand yourself that do violate the standard semantics of your own postfix increment user (§eleven.7.14). stop example
.step 3 Digital providers
Next statutes apply at digital user declarations, in which T denotes the newest for example particular the class otherwise struct who has the fresh new agent report:
- A digital low-shift user shall need a couple parameters, one or more of which should provides sort 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 require partners-wise declaration. For every declaration off both operator of a pair, indeed there will likely be a corresponding statement of one’s most other driver away from the two. Several driver declarations meets in the event the name conversions exists between the come back designs as well as their involved parameter brands. The following operators require partners-smart statement:
Leave a Reply