21 Strings library [strings]

21.3 String classes [string.classes]

21.3.1 Class template basic_string [basic.string]

21.3.1.5 basic_string element access [string.access]

const_reference operator[](size_type pos) const; reference operator[](size_type pos);

Requires: pos <= size().

Returns: *(begin() + pos) if pos < size(). Otherwise, returns a reference to an object of type charT with value charT(), where modifying the object to any value other than charT() leads to undefined behavior.

Throws: Nothing.

Complexity: Constant time.

const_reference at(size_type pos) const; reference at(size_type pos);

Throws: out_of_range if pos >= size().

Returns: operator[](pos).

const charT& front() const; charT& front();

Requires: !empty().

Effects: Equivalent to: return operator[](0);

const charT& back() const; charT& back();

Requires: !empty().

Effects: Equivalent to: return operator[](size() - 1);