Chris@16
|
1
|
Chris@16
|
2 // Copyright (C) 2009-2012 Lorenzo Caminiti
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0
|
Chris@16
|
4 // (see accompanying file LICENSE_1_0.txt or a copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 // Home at http://www.boost.org/libs/local_function
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_LOCAL_FUNCTION_AUX_DECL_HPP_
|
Chris@16
|
9 #define BOOST_LOCAL_FUNCTION_AUX_DECL_HPP_
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/local_function/aux_/macro/code_/result.hpp>
|
Chris@16
|
12 #include <boost/local_function/aux_/macro/code_/bind.hpp>
|
Chris@16
|
13 #include <boost/local_function/aux_/macro/code_/functor.hpp>
|
Chris@16
|
14 #include <boost/local_function/aux_/preprocessor/traits/decl.hpp>
|
Chris@16
|
15 #include <boost/local_function/aux_/preprocessor/traits/decl_error.hpp>
|
Chris@16
|
16 #include <boost/scope_exit.hpp>
|
Chris@16
|
17 #include <boost/mpl/assert.hpp>
|
Chris@16
|
18 #include <boost/preprocessor/control/iif.hpp>
|
Chris@16
|
19 #include <boost/preprocessor/facilities/is_empty.hpp>
|
Chris@16
|
20 #include <boost/preprocessor/list/adt.hpp>
|
Chris@16
|
21 #include <boost/preprocessor/tuple/eat.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 // PRIVATE //
|
Chris@16
|
24
|
Chris@16
|
25 #define BOOST_LOCAL_FUNCTION_AUX_DECL_OK_(id, typename01, decl_traits) \
|
Chris@16
|
26 BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT(id, typename01, decl_traits) \
|
Chris@16
|
27 BOOST_LOCAL_FUNCTION_AUX_CODE_BIND(id, typename01, decl_traits) \
|
Chris@16
|
28 BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR(id, typename01, decl_traits)
|
Chris@16
|
29
|
Chris@16
|
30 #define BOOST_LOCAL_FUNCTION_AUX_DECL_ERROR_(id, typename01, decl_traits) \
|
Chris@16
|
31 BOOST_PP_IIF(BOOST_PP_LIST_IS_CONS( \
|
Chris@16
|
32 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_RETURNS(decl_traits)), \
|
Chris@16
|
33 /* return specified, so no result type before this macro expansion */ \
|
Chris@16
|
34 BOOST_PP_TUPLE_EAT(1) \
|
Chris@16
|
35 , \
|
Chris@16
|
36 /* even if error, must declare result type to prevent additional */ \
|
Chris@16
|
37 /* error due to result type appearing before this macro expansion */ \
|
Chris@16
|
38 BOOST_LOCAL_FUNCTION_AUX_CODE_RESULT_DECL \
|
Chris@16
|
39 )(id) \
|
Chris@16
|
40 ; /* close eventual previous statements, otherwise it has no effect */ \
|
Chris@16
|
41 BOOST_MPL_ASSERT_MSG(false, /* always fails (there's an error) */ \
|
Chris@16
|
42 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR_MSG(decl_traits), ())\
|
Chris@16
|
43 ; /* must close ASSERT macro for eventual use within class scope */
|
Chris@16
|
44
|
Chris@16
|
45 // PUBLIC //
|
Chris@16
|
46
|
Chris@16
|
47 #define BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR \
|
Chris@16
|
48 BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (args) )
|
Chris@16
|
49
|
Chris@16
|
50 // Undefine local function bound args global variable. Actual declaration of
|
Chris@16
|
51 // this variable is made using SFINAE mechanisms by each local function macro.
|
Chris@16
|
52 extern boost::scope_exit::detail::undeclared
|
Chris@16
|
53 BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR;
|
Chris@16
|
54
|
Chris@16
|
55 // sign_params: parsed parenthesized params.
|
Chris@16
|
56 #define BOOST_LOCAL_FUNCTION_AUX_DECL(id, typename01, decl_traits) \
|
Chris@16
|
57 BOOST_PP_IIF(BOOST_PP_IS_EMPTY( \
|
Chris@16
|
58 BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS_ERROR_MSG(decl_traits)), \
|
Chris@16
|
59 BOOST_LOCAL_FUNCTION_AUX_DECL_OK_ \
|
Chris@16
|
60 , \
|
Chris@16
|
61 BOOST_LOCAL_FUNCTION_AUX_DECL_ERROR_ \
|
Chris@16
|
62 )(id, typename01, decl_traits)
|
Chris@16
|
63
|
Chris@16
|
64 #endif // #include guard
|
Chris@16
|
65
|