add cstring::at

This commit is contained in:
Neargye 2018-08-31 18:42:59 +05:00
parent 9597796775
commit b5e635a16e

View file

@ -147,6 +147,11 @@ class cstring final {
constexpr const char& operator[](std::size_t i) const { return str_[i]; }
constexpr const char& at(std::size_t i) const {
return (i < size_) ? str_[i]
: (throw std::out_of_range("cstring::at"), str_[0]);
}
constexpr const char& front() const { return str_[0]; }
constexpr const char& back() const { return str_[size_ - 1]; }