fixstr::basic_fixed_string::at
#1 |
| |
#2 |
|
Returns a reference to the element at specified location pos
, with bounds checking.
If pos is not within the range of the container, an exception of type std::out_of_range
is thrown.
#
Parameterspos
- position of the element to return
#
Return valueReference to the requested element.
#
Exceptionsstd::out_of_range
if pos > size()
.
#
ComplexityConstant.
#
Example#include <fixed_string.hpp>#include <iostream>
int main(){ fixstr::fixed_string str = "Hello, World!"; try { std::cout << str.at(0) << std::endl; std::cout << str.at(25) << std::endl; } catch (std::exception& error) { std::cout << error.what() << std::endl; }}
Possible output:
Harray::at
note
In the implementation the call to at
member function is delegated to std::array
that serves as an underlying storage. That's why error.what()
returns array::at
.