File: overloadable.yo

package info (click to toggle)
c%2B%2B-annotations 8.2.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,804 kB
  • ctags: 2,845
  • sloc: cpp: 15,418; makefile: 2,473; ansic: 165; perl: 90; sh: 29
file content (45 lines) | stat: -rw-r--r-- 2,250 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
The following hi(overloadable operators) operators can be overloaded:
        verb(
    +       -       *       /       %       ^       &       |
    ~       !       ,       =       <       >       <=      >=
    ++      --      <<      >>      ==      !=      &&      ||
    +=      -=      *=      /=      %=      ^=      &=      |=
    <<=     >>=     []      ()      ->      ->*     new     new[]
    delete  delete[]
        )
    Several operators have em(textual alternatives):
        hi(operators: textual alternatives)
    table(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
        )