[857] | 1 | /*=============================================================================
|
---|
| 2 | Copyright (c) 1999-2003 Jaakko Järvi
|
---|
| 3 | Copyright (c) 2001-2003 Joel de Guzman
|
---|
| 4 | Copyright (c) 2004 Peder Holt
|
---|
| 5 |
|
---|
| 6 | Use, modification and distribution is subject to the Boost Software
|
---|
| 7 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 8 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 9 | ==============================================================================*/
|
---|
| 10 | #if !defined(FUSION_SEQUENCE_GET_HPP)
|
---|
| 11 | #define FUSION_SEQUENCE_GET_HPP
|
---|
| 12 |
|
---|
| 13 | #include <boost/spirit/fusion/sequence/at.hpp>
|
---|
| 14 | #include <boost/spirit/fusion/sequence/detail/sequence_base.hpp>
|
---|
| 15 |
|
---|
| 16 | namespace boost { namespace fusion
|
---|
| 17 | {
|
---|
| 18 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 19 | //
|
---|
| 20 | // get function
|
---|
| 21 | //
|
---|
| 22 | // Given a constant integer N and a sequence, returns a reference to
|
---|
| 23 | // the Nth element of the sequence. (N is a zero based index). Usage:
|
---|
| 24 | //
|
---|
| 25 | // get<N>(seq)
|
---|
| 26 | //
|
---|
| 27 | // This function is provided here for compatibility with the tuples TR1
|
---|
| 28 | // specification. This function forwards to at<N>(seq).
|
---|
| 29 | //
|
---|
| 30 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 31 | template <int N, typename Sequence>
|
---|
| 32 | inline typename meta::at_c<Sequence const, N>::type
|
---|
| 33 | get(sequence_base<Sequence> const& seq FUSION_GET_MSVC_WORKAROUND)
|
---|
| 34 | {
|
---|
| 35 | typedef meta::at_c<Sequence const, N> at_meta;
|
---|
| 36 | return meta::at_impl<BOOST_DEDUCED_TYPENAME at_meta::seq::tag>::
|
---|
| 37 | template apply<BOOST_DEDUCED_TYPENAME at_meta::seq const, N>::call(
|
---|
| 38 | at_meta::seq_converter::convert_const(seq.cast()));
|
---|
| 39 |
|
---|
| 40 | // return at<N>(seq.cast());
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | template <int N, typename Sequence>
|
---|
| 44 | inline typename meta::at_c<Sequence, N>::type
|
---|
| 45 | get(sequence_base<Sequence>& seq FUSION_GET_MSVC_WORKAROUND)
|
---|
| 46 | {
|
---|
| 47 | typedef meta::at_c<Sequence, N> at_meta;
|
---|
| 48 | return meta::at_impl<BOOST_DEDUCED_TYPENAME at_meta::seq::tag>::
|
---|
| 49 | template apply<BOOST_DEDUCED_TYPENAME at_meta::seq, N>::call(
|
---|
| 50 | at_meta::seq_converter::convert(seq.cast()));
|
---|
| 51 | // return at<N>(seq.cast());
|
---|
| 52 | }
|
---|
| 53 | }}
|
---|
| 54 |
|
---|
| 55 | #endif
|
---|
| 56 |
|
---|