array::in_range

master
Daniel Kolesa 2015-05-17 22:51:42 +01:00
parent 7e61799f8b
commit 5a991f3e21
1 changed files with 8 additions and 1 deletions

View File

@ -35,9 +35,16 @@ namespace octa {
T &last() noexcept { return p_buf[N - 1]; }
const T &last() const noexcept { return p_buf[N - 1]; }
bool empty() const noexcept { return (N > 0); }
size_t length() const noexcept { return N; }
bool empty() const noexcept { return (N > 0); }
bool in_range(size_t idx) noexcept { return idx < N; }
bool in_range(int idx) noexcept { return idx >= 0 && idx < N; }
bool in_range(const T *ptr) noexcept {
return ptr >= &p_buf[0] && ptr < &p_buf[p_len];
}
T *get() noexcept { return p_buf; }
const T *get() const noexcept { return p_buf; }