File: initializers.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 (33 lines) | stat: -rw-r--r-- 1,718 bytes parent folder | download | duplicates (2)
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
After defining string objects they are guaranteed to be in a valid
state. At em(definition time)  string objects may be initialized in one of the
following ways:
    The following tt(string) constructors hi(string constructors) are
available:
    itemization(
    ittq(string object)
       (initializes tt(object) to an empty string.  When defining a tt(string)
        this way no argument list may be specified;)
    ittq(string object(string::size_type count, char ch))
       (initializes tt(object) with tt(count) characters tt(ch). em(Caveat:)
        to initialize a string object using this constructor do not use the
        curly braces variant, but use the constructor as shown, to avoid
        selecting the initializer-list constructor (see below);)
    ittq(string object(string const &argument))
        (initializes tt(object) with tt(argument);)
    ittq(string object(std::string const &argument, string::size_type
            apos, string::size_type an))
       (initializes tt(object) with tt(argument)'s content starting at index
        position tt(apos), using at most tt(an) of tt(argument)'s characters;)
    ittq(string object(InputIterator begin, InputIterator end))
       (initializes tt(object) with the characters in the range of characters
        defined by the two tt(InputIterators).)
    ittq(string object(std::initializer_list<char> chars))
       (initializes tt(object) with the characters specified in the 
        initializer list. The string may also directly be initialized, using
        the curly braced initialization. Here is an example showing both
        forms: 
       verb(string str1({'h', 'e', 'l', 'l', 'o'});
string str2{ 'h', 'e', 'l', 'l', 'o' };)

)
    )