old-nall/vector/access.hpp

40 lines
872 B
C++
Raw Permalink Normal View History

2016-07-03 11:35:22 +00:00
#pragma once
namespace nall {
template<typename T> auto vector<T>::operator[](uint offset) -> T& {
return _pool[offset];
}
template<typename T> auto vector<T>::operator[](uint offset) const -> const T& {
return _pool[offset];
}
template<typename T> auto vector<T>::operator()(uint offset) -> T& {
while(offset >= size()) append(T());
return _pool[offset];
}
template<typename T> auto vector<T>::operator()(uint offset, const T& value) const -> const T& {
if(offset >= size()) return value;
return _pool[offset];
}
template<typename T> auto vector<T>::left() -> T& {
return _pool[0];
}
template<typename T> auto vector<T>::left() const -> const T& {
return _pool[0];
}
template<typename T> auto vector<T>::right() -> T& {
return _pool[_size - 1];
}
template<typename T> auto vector<T>::right() const -> const T& {
return _pool[_size - 1];
}
}