Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:41:54

0001 /*==============================================================================
0002     Copyright (c) 2013 Jamboree
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 #ifndef BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED
0008 #define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED
0009 
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/mpl/bool.hpp>
0013 #include <boost/mpl/single_view.hpp>
0014 #include <boost/fusion/support/detail/access.hpp>
0015 #include <boost/fusion/support/is_view.hpp>
0016 #include <boost/fusion/support/category_of.hpp>
0017 #include <boost/fusion/support/sequence_base.hpp>
0018 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0019 #include <boost/fusion/sequence/intrinsic/end.hpp>
0020 #include <boost/fusion/view/flatten_view/flatten_view_iterator.hpp>
0021 
0022 #ifdef _MSC_VER
0023 #  pragma warning(push)
0024 #  pragma warning(disable: 4512) // assignment operator could not be generated.
0025 #endif
0026 
0027 namespace boost { namespace fusion
0028 {
0029     struct forward_traversal_tag;
0030     struct flatten_view_tag;
0031 
0032     template <typename Sequence>
0033     struct flatten_view
0034       : sequence_base<flatten_view<Sequence> >
0035     {
0036         typedef flatten_view_tag fusion_tag;
0037         typedef fusion_sequence_tag tag; // this gets picked up by MPL
0038         typedef mpl::true_ is_view;
0039         typedef forward_traversal_tag category;
0040 
0041         typedef Sequence sequence_type;
0042         typedef typename result_of::begin<Sequence>::type first_type;
0043         typedef typename result_of::end<Sequence>::type last_type;
0044 
0045         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0046         explicit flatten_view(Sequence& seq)
0047           : seq(seq)
0048         {}
0049 
0050         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0051         first_type first() const { return fusion::begin(seq); }
0052         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0053         last_type last() const { return fusion::end(seq); }
0054 
0055         typename mpl::if_<traits::is_view<Sequence>, Sequence, Sequence&>::type seq;
0056     };
0057 }}
0058 
0059 #ifdef _MSC_VER
0060 #  pragma warning(pop)
0061 #endif
0062 
0063 namespace boost { namespace fusion { namespace extension
0064 {
0065     template<>
0066     struct begin_impl<flatten_view_tag>
0067     {
0068         template<typename Sequence>
0069         struct apply
0070         {
0071             typedef typename Sequence::first_type first_type;
0072 
0073             typedef typename
0074                     result_of::begin<
0075                         mpl::single_view<
0076                             typename Sequence::sequence_type> >::type
0077             root_iterator;
0078 
0079             typedef
0080                 detail::seek_descent<root_iterator, first_type>
0081             seek_descent;
0082 
0083             typedef typename seek_descent::type type;
0084 
0085             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0086             static inline
0087             type call(Sequence& seq)
0088             {
0089                 return seek_descent::apply(root_iterator(), seq.first());
0090             }
0091         };
0092     };
0093 
0094     template<>
0095     struct end_impl<flatten_view_tag>
0096     {
0097         template<typename Sequence>
0098         struct apply
0099         {
0100             typedef typename Sequence::last_type last_type;
0101 
0102             typedef typename
0103                     result_of::end<
0104                         mpl::single_view<
0105                             typename Sequence::sequence_type> >::type
0106             type;
0107 
0108             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0109             static inline
0110             type call(Sequence&)
0111             {
0112                 return type();
0113             }
0114         };
0115     };
0116 
0117     template<>
0118     struct size_impl<flatten_view_tag>
0119     {
0120         template <typename Sequence>
0121         struct apply
0122           : result_of::distance
0123             <
0124                 typename result_of::begin<Sequence>::type
0125               , typename result_of::end<Sequence>::type
0126             >
0127         {};
0128     };
0129 
0130     template<>
0131     struct empty_impl<flatten_view_tag>
0132     {
0133         template <typename Sequence>
0134         struct apply
0135           : result_of::empty<typename Sequence::sequence_type>
0136         {};
0137     };
0138 }}}
0139 
0140 
0141 #endif