fixstr::basic_fixed_string::operator[]
#1 |
| |
#2 |
|
Returns a reference to the character at specified location pos. No bounds checking is performed.
If pos > size()
, the behavior is undefined.
If pos == size()
, a reference to the character with value TChar()
(the null character) is returned.
For the first (non-const) version, the behavior is undefined if this character is modified to any value other than TChar()
.
#
Parameterspos
- position of the element to return
#
Return valueReference to the requested element.
#
ComplexityConstant.
#
Example#include <cctype>#include <fixed_string.hpp>#include <iostream>
int main(){ fixstr::fixed_string str = "Hello, World!"; std::cout << str << std::endl;
str[0] = std::tolower(str[0]); str[7] = std::tolower(str[7]);
std::cout << str << std::endl;
// [[maybe_unused]] const auto foo = str[25]; // Undefined behaviour: the index is out of range}
Hello, World!hello, world!