• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright (C) 2008-2018 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0 (see accompanying
4 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
6 
7 #include "separate_body.hpp"
8 #include <cassert>
9 
10 //[separate_body_cpp
constructor_body(unsigned max,unsigned count)11 void iarray::constructor_body(unsigned max, unsigned count) {
12     for(unsigned i = 0; i < count; ++i) values_[i] = int();
13     size_ = count;
14 }
15 
destructor_body()16 void iarray::destructor_body() { delete[] values_; }
17 
push_back_body(int value)18 void iarray::push_back_body(int value) { values_[size_++] = value; }
19 
20 /* ... */
21 //]
22 
capacity_body() const23 unsigned iarray::capacity_body() const { return capacity_; }
size_body() const24 unsigned iarray::size_body() const { return size_; }
25 
main()26 int main() {
27     iarray a(3, 2);
28     assert(a.capacity() == 3);
29     assert(a.size() == 2);
30 
31     a.push_back(-123);
32     assert(a.size() == 3);
33 
34     return 0;
35 }
36 
37