File indexing completed on 2025-01-18 09:31:17
0001
0002
0003
0004
0005
0006
0007 #if !defined(FUSION_INSERT_07222005_0730)
0008 #define FUSION_INSERT_07222005_0730
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/support/detail/as_fusion_element.hpp>
0012 #include <boost/fusion/iterator/mpl/convert_iterator.hpp>
0013 #include <boost/fusion/view/joint_view/joint_view.hpp>
0014 #include <boost/fusion/view/single_view/single_view.hpp>
0015 #include <boost/fusion/view/iterator_range/iterator_range.hpp>
0016 #include <boost/fusion/sequence/intrinsic/begin.hpp>
0017 #include <boost/fusion/sequence/intrinsic/end.hpp>
0018 #include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
0019 #include <boost/fusion/support/is_sequence.hpp>
0020 #include <boost/utility/enable_if.hpp>
0021
0022 namespace boost { namespace fusion
0023 {
0024 namespace result_of
0025 {
0026 template <typename Sequence, typename Position, typename T>
0027 struct insert
0028 {
0029 typedef typename detail::as_fusion_element<T>::type element_type;
0030 typedef typename convert_iterator<Position>::type pos_type;
0031 typedef typename result_of::begin<Sequence>::type first_type;
0032 typedef typename result_of::end<Sequence>::type last_type;
0033
0034 typedef iterator_range<first_type, pos_type> left_type;
0035 typedef iterator_range<pos_type, last_type> right_type;
0036 typedef fusion::single_view<element_type> single_view;
0037 typedef joint_view<left_type, single_view const> left_insert_type;
0038 typedef joint_view<left_insert_type, right_type> type;
0039 };
0040 }
0041
0042 template <typename Sequence, typename Position, typename T>
0043 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0044 inline typename
0045 lazy_enable_if<
0046 traits::is_sequence<Sequence>
0047 , result_of::insert<Sequence const, Position, T>
0048 >::type
0049 insert(Sequence const& seq, Position const& pos, T const& x)
0050 {
0051 typedef result_of::insert<
0052 Sequence const, Position, T>
0053 result_of;
0054 typedef typename result_of::left_type left_type;
0055 typedef typename result_of::right_type right_type;
0056 typedef typename result_of::single_view single_view;
0057 typedef typename result_of::left_insert_type left_insert_type;
0058 typedef typename result_of::type result;
0059
0060 left_type left(fusion::begin(seq), convert_iterator<Position>::call(pos));
0061 right_type right(convert_iterator<Position>::call(pos), fusion::end(seq));
0062 single_view insert(x);
0063 left_insert_type left_insert(left, insert);
0064 return result(left_insert, right);
0065 }
0066 }}
0067
0068 #endif
0069