-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScopeArray.cpp
More file actions
65 lines (53 loc) · 1.37 KB
/
ScopeArray.cpp
File metadata and controls
65 lines (53 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* \file ScopeArray.cpp
* \brief boost::scoped_array
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
#if BOOST_VERSION > 0
#include <boost/scoped_array.hpp>
//-------------------------------------------------------------------------------------------------
class Printer
{
public:
Printer() :
_id{_count ++}
{
std::cout << __FUNCTION__ << ": " << STD_TRACE_VAR2(_count, _id) << std::endl;
}
~Printer()
{
std::cout << __FUNCTION__ << ": " << STD_TRACE_VAR2(_count, _id) << std::endl;
}
private:
static inline int _count {};
int _id {};
};
//-------------------------------------------------------------------------------------------------
#endif
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
#if BOOST_VERSION > 0
{
boost::scoped_array<Printer> p2(new Printer[5]);
}
#else
std::cout << "Boost - not instaled, skip" << std::endl;
#endif
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
Printer: _count: 1, _id: 0
Printer: _count: 2, _id: 1
Printer: _count: 3, _id: 2
Printer: _count: 4, _id: 3
Printer: _count: 5, _id: 4
~Printer: _count: 5, _id: 4
~Printer: _count: 5, _id: 3
~Printer: _count: 5, _id: 2
~Printer: _count: 5, _id: 1
~Printer: _count: 5, _id: 0
#endif