25 typedef std::vector<T> vector;
26 typedef typename vector::value_type value_type;
27 typedef typename vector::iterator iterator;
28 typedef typename vector::const_iterator const_iterator;
29 typedef typename vector::reverse_iterator reverse_iterator;
30 typedef typename vector::const_reverse_iterator const_reverse_iterator;
31 typedef typename vector::size_type size_type;
32 typedef typename vector::reference reference;
33 typedef typename vector::const_reference const_reference;
42 iterator begin() {
return vector_.begin(); }
43 iterator end() {
return vector_.end(); }
44 const_iterator begin()
const {
return vector_.cbegin(); }
45 const_iterator end()
const {
return vector_.cend(); }
46 const_iterator cbegin()
const {
return vector_.cbegin(); }
47 const_iterator cend()
const {
return vector_.cend(); }
48 reverse_iterator rbegin() {
return vector_.rbegin(); }
49 reverse_iterator rend() {
return vector_.rend(); }
50 const_reverse_iterator rbegin()
const {
return vector_.crbegin(); }
51 const_reverse_iterator rend()
const {
return vector_.crend(); }
52 const_reverse_iterator crbegin()
const {
return vector_.crbegin(); }
53 const_reverse_iterator crend()
const {
return vector_.crend(); }
55 void push_back(value_type
const &v) { vector_.push_back(v); }
56 void push_back(value_type &&v) { vector_.push_back(std::move(v)); }
57 void push() { scopes_.push_back(vector_.size()); }
59 if (scopes_.empty()) {
60 throw std::runtime_error(
"Nothing to pop.");
63 size_t const prev_size = scopes_.back();
65 size_t cur_size = vector_.size();
66 while (cur_size-- > prev_size) {
73 [[nodiscard]]
bool empty()
const {
return vector_.empty(); }
74 [[nodiscard]]
size_t size()
const {
return vector_.size(); }
75 [[nodiscard]] vector
const &get_vector()
const {
return vector_; }
76 [[nodiscard]] vector get_vector() {
return vector_; }
78 reference first() {
return vector_.at(0); }
79 const_reference first()
const {
return vector_.at(0); }
80 reference last() {
return vector_.at(size() - 1); }
81 const_reference last()
const {
return vector_.at(size() - 1); }
82 reference operator[](size_type n) {
return vector_[n]; }
83 const_reference operator[](size_type n)
const {
return vector_[n]; }
85 for (
size_t i = 0; i < vector_.size(); i++) {
86 if (vector_[i] < v.vector_[i]) {
92 vector get_reverse()
const {
94 std::reverse(tmp.begin(), tmp.end());
98 friend std::ostream &operator<<(std::ostream &os,
ScopedVector<T> const &v) {
99 for (
auto const &e : v) os << e << std::endl;
105 std::vector<size_t> scopes_;