mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
Add the at() method to C++ vectors.
* There is no reason not to have this.
This commit is contained in:
parent
4501776089
commit
850f2d1e58
@ -31,6 +31,8 @@
|
||||
#ifndef __SGI_STL_INTERNAL_VECTOR_H
|
||||
#define __SGI_STL_INTERNAL_VECTOR_H
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
__STL_BEGIN_NAMESPACE
|
||||
|
||||
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
|
||||
@ -218,6 +220,18 @@ public:
|
||||
reference operator[](size_type __n) { return *(begin() + __n); }
|
||||
const_reference operator[](size_type __n) const { return *(begin() + __n); }
|
||||
|
||||
reference at(size_type __n) {
|
||||
if (__n >= size())
|
||||
throw std::out_of_range("vector::at() out_of_range");
|
||||
return *(begin() + __n);
|
||||
}
|
||||
|
||||
const_reference at(size_type __n) const {
|
||||
if (__n >= size())
|
||||
throw std::out_of_range("vector::at() out_of_range");
|
||||
return *(begin() + __n);
|
||||
}
|
||||
|
||||
explicit vector(const allocator_type& __a = allocator_type())
|
||||
: _Base(__a) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user