assert C++ (Problem understanding the code)

I have problem understanding this code. I don't understand what is going on from assert code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 void append(int x) {
       if (size >= capacity) {
          capacity = 2 * capacity;          // double the capacity
          int* new_arr = new int[capacity]; // make new underlying array
                                            // twice size of old one

          for(int i = 0; i < size; ++i) {   // copy elements of v
             new_arr[i] = arr[i];           // into new_arr
          }

          delete[] arr;                     // delete old arr

          arr = new_arr;                    // assign new_arr
       }

       // What happens after here ?
       assert(size < capacity);
       arr[size] = x;
       size++;
   }
Topic archived. No new replies allowed.