Ticket #1113: simple.cpp

File simple.cpp, 699 bytes (added by Nathan Crookston <nathan.crookston@…>, 13 years ago)

Test code

Line 
1
2#include "boost/shared_array.hpp"
3#include <iostream>
4
5struct B {};
6
7struct D : public B {};
8
9int main()
10{
11#if 1
12 boost::shared_array<int> pInt(new int[50]);
13 boost::shared_array<const int> pIntConst1(pInt);
14 boost::shared_array<int> pInt2;
15 pInt2 = pInt;
16 boost::shared_array<const int> pIntConst2(pIntConst1);
17 boost::shared_array<const int> pIntConst3;
18 pIntConst3 = pIntConst1;
19
20 std::cout << "Use count: " << pInt.use_count() << std::endl;
21
22 boost::shared_array<D> pD(new D[50]);
23 boost::shared_array<const D> pD2(pD);
24 std::cout << "Use count: " << pD2.use_count() << std::endl;
25#else
26 boost::shared_array<D> pD(new D[50]);
27 boost::shared_array<B> pB(pD);
28
29#endif
30 return 0;
31}
32