]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/scope_exit/test/same_line.cpp
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_CXX11_VARIADIC_MACROS
11 # error "variadic macros required"
14 #include <boost/scope_exit.hpp>
15 #include <boost/preprocessor/cat.hpp>
16 #include <boost/detail/lightweight_test.hpp>
19 #define SCOPE_EXIT_INC_DEC(variable, offset) \
20 BOOST_SCOPE_EXIT_ID(BOOST_PP_CAT(inc, __LINE__), /* unique ID */ \
21 &variable, offset) { \
23 } BOOST_SCOPE_EXIT_END_ID(BOOST_PP_CAT(inc, __LINE__)) \
25 BOOST_SCOPE_EXIT_ID(BOOST_PP_CAT(dec, __LINE__), \
26 &variable, offset) { \
28 } BOOST_SCOPE_EXIT_END_ID(BOOST_PP_CAT(dec, __LINE__))
30 #define SCOPE_EXIT_INC_DEC_TPL(variable, offset) \
31 BOOST_SCOPE_EXIT_ID_TPL(BOOST_PP_CAT(inc, __LINE__), \
32 &variable, offset) { \
34 } BOOST_SCOPE_EXIT_END_ID(BOOST_PP_CAT(inc, __LINE__)) \
36 BOOST_SCOPE_EXIT_ID_TPL(BOOST_PP_CAT(dec, __LINE__), \
37 &variable, offset) { \
39 } BOOST_SCOPE_EXIT_END_ID(BOOST_PP_CAT(dec, __LINE__))
41 #define SCOPE_EXIT_ALL_INC_DEC(variable, offset) \
42 BOOST_SCOPE_EXIT_ALL_ID(BOOST_PP_CAT(inc, __LINE__), \
46 BOOST_SCOPE_EXIT_ALL_ID(BOOST_PP_CAT(dec, __LINE__), \
52 void f(T
& x
, T
& delta
) {
53 SCOPE_EXIT_INC_DEC_TPL(x
, delta
) // Multiple scope exits on same line.
58 int x
= 0, delta
= 10;
61 SCOPE_EXIT_INC_DEC(x
, delta
) // Multiple scope exits on same line.
67 #ifndef BOOST_NO_CXX11_LAMBDAS
69 SCOPE_EXIT_ALL_INC_DEC(x
, delta
) // Multiple scope exits on same line.
74 return boost::report_errors();
78 #endif // variadic macros