source: NonGTP/Boost/boost/spirit/fusion/sequence/at.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 19 years ago (diff)
Line 
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_AT_HPP)
11#define FUSION_SEQUENCE_AT_HPP
12
13#include <boost/spirit/fusion/detail/config.hpp>
14#include <boost/spirit/fusion/sequence/as_fusion_sequence.hpp>
15#include <boost/spirit/fusion/sequence/detail/sequence_base.hpp>
16
17namespace boost { namespace fusion
18{
19    namespace meta
20    {
21        template <typename Tag>
22        struct at_impl
23        {
24            template <typename Sequence, int N>
25            struct apply;
26        };
27
28        template <typename Sequence, int N>
29        struct at_c
30        {
31            typedef as_fusion_sequence<Sequence> seq_converter;
32            typedef typename seq_converter::type seq;
33
34            typedef typename
35                at_impl<FUSION_GET_TAG(seq)>::
36                    template apply<seq, N>::type
37            type;
38        };
39
40        template <typename Sequence, typename N>
41        struct at : at_c<Sequence, N::value> {};
42    }
43#if! BOOST_WORKAROUND(BOOST_MSVC, < 1300)
44    template <int N, typename Sequence>
45    inline typename meta::at_c<Sequence const, N>::type
46    at(sequence_base<Sequence> const& seq FUSION_GET_MSVC_WORKAROUND)
47    {
48        typedef meta::at_c<Sequence const, N> at_meta;
49        return meta::at_impl<typename at_meta::seq::tag>::
50            template apply<typename at_meta::seq const, N>::call(
51                at_meta::seq_converter::convert_const(seq.cast()));
52    }
53
54    template <int N, typename Sequence>
55    inline typename meta::at_c<Sequence, N>::type
56    at(sequence_base<Sequence>& seq FUSION_GET_MSVC_WORKAROUND)
57    {
58        typedef meta::at_c<Sequence, N> at_meta;
59        return meta::at_impl<typename at_meta::seq::tag>::
60            template apply<typename at_meta::seq, N>::call(
61                at_meta::seq_converter::convert(seq.cast()));
62    }
63#endif
64}}
65
66#endif
67
Note: See TracBrowser for help on using the repository browser.