About
Contact
QtCreator
KDevelop
Solarized
1
2
// Copyright (C) 2006-2009, 2012 Alexander Nasonov
3
// Copyright (C) 2012 Lorenzo Caminiti
4
// Distributed under the Boost Software License, Version 1.0
5
// (see accompanying file LICENSE_1_0.txt or a copy at
6
//
http://www.boost.org/LICENSE_1_0.txt
)
7
// Home at
http://www.boost.org/libs/scope_exit
8
9
#include
<boost/scope_exit.hpp>
10
#include
<boost/config.hpp>
11
#include
<boost/typeof/typeof.hpp>
12
#include
BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP
()
13
#include
<boost/detail/lightweight_test.hpp>
14
15
struct
this_tester
;
16
BOOST_TYPEOF_REGISTER_TYPE
(this_tester)
// Register before `this_` capture.
17
18
struct
this_tester
{
19
void
check
(
void
) {
20
value_
= -
1
;
21
22
BOOST_SCOPE_EXIT
( (this_) ) {
23
BOOST_TEST
(
this_
->
value_
==
0
);
24
}
BOOST_SCOPE_EXIT_END
25
26
#
ifndef
BOOST_NO_CXX11_LAMBDAS
27
BOOST_SCOPE_EXIT_ALL
(&,
this
) {
28
BOOST_TEST
(
this
->
value_
==
0
);
29
};
30
#
endif
// lambdas
31
32
value_
=
0
;
33
}
34
35
private
:
36
int
value_
;
37
};
38
39
int
main
(
void
) {
40
this_tester
(
).
check
();
41
return
boost::
report_errors
();
42
}
43
44