~ubuntu-branches/ubuntu/trusty/c++-annotations/trusty

« back to all changes in this revision

Viewing changes to yo/string/operators.yo

  • Committer: Package Import Robot
  • Author(s): tony mancill, Frank B. Brokken, tony mancill
  • Date: 2014-01-18 08:55:27 UTC
  • mfrom: (1.1.26)
  • Revision ID: package-import@ubuntu.com-20140118085527-ph5upqqn423cmnmz
Tags: 9.8.0-1
[ Frank B. Brokken ]
* New upstream release, adds a section about static polymorphism, removes
  the concrete/a2x section, and removes C++11 indicators from the section
  headers. 

[ tony mancill ]
* Use debhelper 9.
* Tweak build-deps for g++ to use >= 4.8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
    it() plain assignment:
10
10
    quote(a character, bf(C) or bf(C++) string may be assigned to a tt(string)
11
11
object. The assignment operator returns its left-hand side operand. Example:
12
 
        verb(
13
 
    object =  argument;
14
 
    object = "C string";
15
 
    object = 'x';
16
 
    object = 120;       // same as object = 'x'
 
12
    verb(
 
13
object =  argument;
 
14
object = "C string";
 
15
object = 'x';
 
16
object = 120;       // same as object = 'x'
17
17
        )
18
18
    )
19
19
    it() addition:
24
24
left-hand side operand or the right-hand side operand must be a
25
25
tt(std::string) object. The other operand may be a char, a bf(C) string or a
26
26
bf(C++) string. Example:
27
 
        verb(
28
 
    object += argument;
29
 
    object += "hello";
30
 
    object += 'x';      // integral expressions are OK
 
27
    verb(
 
28
object += argument;
 
29
object += "hello";
 
30
object += 'x';      // integral expressions are OK
31
31
 
32
 
    argument + otherArgument;   // two std::string objects
33
 
    argument + "hello";         // using + at least one
34
 
    "hello" + argument;         // std::string is required
35
 
    argument + 'a';             // integral expressions are OK
36
 
    'a' + argument;
 
32
argument + otherArgument;   // two std::string objects
 
33
argument + "hello";         // using + at least one
 
34
"hello" + argument;         // std::string is required
 
35
argument + 'a';             // integral expressions are OK
 
36
'a' + argument;
37
37
            )
38
38
    )
39
39
    it() index operator:
42
42
non-const string object. There is no range-checking (use the tt(at()) member
43
43
function for that). This operator returns a tt(char &) or tt(char const &).
44
44
Example:
45
 
        verb(
46
 
    object[3] = argument[5];
 
45
    verb(
 
46
object[3] = argument[5];
47
47
        )
48
48
    )
49
49
    it() logical operators:
53
53
The tt(==, !=, >, >=, <,) and tt(<=) operators are available. The ordering
54
54
operators perform a lexicographical comparison of their contents
55
55
using the ASCII character collating sequence. Example:
56
 
        verb(
57
 
    object == object;           // true
58
 
    object != (object + 'x');   // true
59
 
    object <= (object + 'x');   // true
 
56
    verb(
 
57
object == object;           // true
 
58
object != (object + 'x');   // true
 
59
object <= (object + 'x');   // true
60
60
        )
61
61
    )
62
62
    it() stream related operators:
68
68
character array may be extracted as well, but the advantage of using a string
69
69
object should be clear: the destination string object is automatically resized
70
70
to the required number of characters. Example:
71
 
        verb(
72
 
    cin >> object;
73
 
    cout << object;
 
71
    verb(
 
72
cin >> object;
 
73
cout << object;
74
74
        )
75
75
    )
76
76
    )