File indexing completed on 2025-01-18 09:31:17
0001
0002
0003
0004
0005
0006
0007 #if !defined(FUSION_ERASE_07232005_0534)
0008 #define FUSION_ERASE_07232005_0534
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/iterator/equal_to.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/iterator_range/iterator_range.hpp>
0015 #include <boost/fusion/support/detail/as_fusion_element.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 #include <boost/mpl/if.hpp>
0022
0023 namespace boost { namespace fusion
0024 {
0025 namespace result_of
0026 {
0027 template <typename Sequence, typename First>
0028 struct compute_erase_last
0029 {
0030 typedef typename result_of::end<Sequence>::type seq_last_type;
0031 typedef typename convert_iterator<First>::type first_type;
0032 typedef typename
0033 mpl::if_<
0034 result_of::equal_to<first_type, seq_last_type>
0035 , first_type
0036 , typename result_of::next<first_type>::type
0037 >::type
0038 type;
0039
0040 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0041 static type
0042 call(First const& first, mpl::false_)
0043 {
0044 return fusion::next(convert_iterator<First>::call(first));
0045 }
0046
0047 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0048 static type
0049 call(First const& first, mpl::true_)
0050 {
0051 return convert_iterator<First>::call(first);
0052 }
0053
0054 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0055 static type
0056 call(First const& first)
0057 {
0058 return call(first, result_of::equal_to<first_type, seq_last_type>());
0059 }
0060 };
0061
0062 struct use_default;
0063
0064 template <class T, class Default>
0065 struct fusion_default_help
0066 : mpl::if_<
0067 is_same<T, use_default>
0068 , Default
0069 , T
0070 >
0071 {
0072 };
0073
0074 template <
0075 typename Sequence
0076 , typename First
0077 , typename Last = use_default>
0078 struct erase
0079 {
0080 typedef typename result_of::begin<Sequence>::type seq_first_type;
0081 typedef typename result_of::end<Sequence>::type seq_last_type;
0082 BOOST_STATIC_ASSERT((!result_of::equal_to<seq_first_type, seq_last_type>::value));
0083
0084 typedef First FirstType;
0085 typedef typename
0086 fusion_default_help<
0087 Last
0088 , typename compute_erase_last<Sequence, First>::type
0089 >::type
0090 LastType;
0091
0092 typedef typename convert_iterator<FirstType>::type first_type;
0093 typedef typename convert_iterator<LastType>::type last_type;
0094 typedef iterator_range<seq_first_type, first_type> left_type;
0095 typedef iterator_range<last_type, seq_last_type> right_type;
0096 typedef joint_view<left_type, right_type> type;
0097 };
0098 }
0099
0100 template <typename Sequence, typename First>
0101 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0102 inline typename
0103 lazy_enable_if<
0104 traits::is_sequence<Sequence>
0105 , typename result_of::erase<Sequence const, First>
0106 >::type
0107 erase(Sequence const& seq, First const& first)
0108 {
0109 typedef result_of::erase<Sequence const, First> result_of;
0110 typedef typename result_of::left_type left_type;
0111 typedef typename result_of::right_type right_type;
0112 typedef typename result_of::type result_type;
0113
0114 left_type left(
0115 fusion::begin(seq)
0116 , convert_iterator<First>::call(first));
0117 right_type right(
0118 fusion::result_of::compute_erase_last<Sequence const, First>::call(first)
0119 , fusion::end(seq));
0120 return result_type(left, right);
0121 }
0122
0123 template <typename Sequence, typename First, typename Last>
0124 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0125 inline typename result_of::erase<Sequence const, First, Last>::type
0126 erase(Sequence const& seq, First const& first, Last const& last)
0127 {
0128 typedef result_of::erase<Sequence const, First, Last> result_of;
0129 typedef typename result_of::left_type left_type;
0130 typedef typename result_of::right_type right_type;
0131 typedef typename result_of::type result_type;
0132
0133 left_type left(fusion::begin(seq), first);
0134 right_type right(last, fusion::end(seq));
0135 return result_type(left, right);
0136 }
0137 }}
0138
0139 #endif
0140