File: overloadable.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (48 lines) | stat: -rw-r--r-- 2,313 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
The following hi(overloadable operators) operators can be overloaded:
        verb(    +       -       *       /       %       ^       &       |
    ~       !       ,       =       <=>     <       >       <=
    >=      ++      --      <<      >>      ==      !=      &&
    ||      +=      -=      *=      /=      %=      ^=      &=
    |=      <<=     >>=     []      ()      ->      ->*     new
    new[]   delete  delete[])

Several operators have em(textual alternatives):

    center(
    attrib(style="margin-left:auto;margin-right:auto;")
        hi(operators: textual alternatives)
    tableatt(2)(cl)(
    rowline()
    row(cell(textual alternative)               cell(operator))
    rowline()
    row(cell(  ti(and)hi(operator and))       cell(tt( && )))
    row(cell(  ti(and_eq)hi(operator and_eq)) cell(tt( &= )))
    row(cell(  ti(bitand)hi(operator bitand)) cell(tt( &  )))
    row(cell(  ti(bitor)hi(operator bitor))   cell(tt( |  )))
    row(cell(  ti(compl)hi(operator compl))   cell(tt( ~  )))
    row(cell(  ti(not)hi(operator not))       cell(tt( !  )))
    row(cell(  ti(not_eq)hi(operator not_eq)) cell(tt( != )))
    row(cell(  ti(or)hi(operator or))         cell(tt( || )))
    row(cell(  ti(or_eq)hi(operator or_eq))   cell(tt( |= )))
    row(cell(  ti(xor)hi(operator xor))       cell(tt( ^  )))
    row(cell(  ti(xor_eq)hi(operator xor_eq)) cell(tt( ^= )))
    rowline()
    )
    )

    `Textual' alternatives of operators are also overloadable (e.g.,
tt(operator and)). However, note that textual alternatives are not
em(additional) operators. So, within the same context tt(operator&&) and
tt(operator and) can not em(both) be overloaded.

    Several of these operators may only be overloaded as member functions
    hi(operator overloading: within classes only) em(within) a class. This
holds true for the tt('='), the tt('[]'), the tt('()') and the tt('->')
operators. Consequently, it isn't possible to redefine, e.g., the assignment
operator globally in such a way that it accepts a tt(char const *) as an
tt(lvalue) and a tt(String &) as an em(rvalue). Fortunately, that isn't
necessary either, as we have seen in section ref(ConversionOperators).

    Finally, the following operators cannot be  overloaded:
        verb(    .       .*      ::      ?:      sizeof  typeid)