1 | /*=============================================================================
|
---|
2 | Copyright (c) 1999-2003 Jaakko Järvi
|
---|
3 | Copyright (c) 2001-2003 Joel de Guzman
|
---|
4 |
|
---|
5 | Use, modification and distribution is subject to the Boost Software
|
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
7 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
8 | ==============================================================================*/
|
---|
9 | #if !defined(FUSION_SEQUENCE_TIE_HPP)
|
---|
10 | #define FUSION_SEQUENCE_TIE_HPP
|
---|
11 |
|
---|
12 | #include <boost/ref.hpp>
|
---|
13 | #include <boost/preprocessor/repetition/enum.hpp>
|
---|
14 | #include <boost/preprocessor/repetition/enum_params.hpp>
|
---|
15 | #include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
---|
16 | #include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
---|
17 | #include <boost/spirit/fusion/sequence/tuple.hpp>
|
---|
18 |
|
---|
19 | namespace boost { namespace fusion
|
---|
20 | {
|
---|
21 | // Swallows any assignment (by Doug Gregor)
|
---|
22 | namespace detail
|
---|
23 | {
|
---|
24 | struct swallow_assign
|
---|
25 | {
|
---|
26 | template<typename T>
|
---|
27 | swallow_assign const&
|
---|
28 | operator=(const T&) const
|
---|
29 | {
|
---|
30 | return *this;
|
---|
31 | }
|
---|
32 | };
|
---|
33 | }
|
---|
34 |
|
---|
35 | // "ignore" allows tuple positions to be ignored when using "tie".
|
---|
36 | detail::swallow_assign const ignore = detail::swallow_assign();
|
---|
37 |
|
---|
38 | #define FUSION_REFERENCE_TYPE(z, n, data) \
|
---|
39 | BOOST_PP_CAT(T, n)&
|
---|
40 |
|
---|
41 | #define FUSION_TIE(z, n, _) \
|
---|
42 | \
|
---|
43 | template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
---|
44 | inline tuple<BOOST_PP_ENUM(n, FUSION_REFERENCE_TYPE, _)> \
|
---|
45 | tie(BOOST_PP_ENUM_BINARY_PARAMS(n, T, & _)) \
|
---|
46 | { \
|
---|
47 | return tuple<BOOST_PP_ENUM(n, FUSION_REFERENCE_TYPE, _)>( \
|
---|
48 | BOOST_PP_ENUM_PARAMS(n, _)); \
|
---|
49 | }
|
---|
50 |
|
---|
51 | BOOST_PP_REPEAT_FROM_TO(1, FUSION_MAX_TUPLE_SIZE, FUSION_TIE, _)
|
---|
52 |
|
---|
53 | #undef FUSION_REFERENCE_TYPE
|
---|
54 | #undef FUSION_TIE
|
---|
55 |
|
---|
56 | }}
|
---|
57 |
|
---|
58 | #endif
|
---|