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
9 #include <boost/config.hpp>
10 #ifdef BOOST_NO_LAMBDAS
11 # error "lambda functions required"
14 #include <boost/detail/lightweight_test.hpp>
20 void add_person(person const& a_person);
21 std::vector<person> persons_;
28 scope_exit(std::function<void (void)> f) : f_(f) {}
29 ~scope_exit(void) { f_(); }
31 std::function<void (void)> f_;
34 void world::add_person(person const& a_person) {
37 persons_.push_back(a_person);
38 scope_exit on_exit1([&commit, this](void) { // Use C++11 lambda.
39 if(!commit) persons_.pop_back(); // `persons_` via captured `this`.
52 BOOST_TEST(w.persons_.size() == 1);
53 return boost::report_errors();