diff --git a/include/boost/container/experimental/segmented_iterator_traits.hpp b/include/boost/container/experimental/segmented_iterator_traits.hpp index 8a4733a..82de826 100644 --- a/include/boost/container/experimental/segmented_iterator_traits.hpp +++ b/include/boost/container/experimental/segmented_iterator_traits.hpp @@ -20,6 +20,7 @@ #include #include +#include #include @@ -56,6 +57,24 @@ struct segduo BOOST_CONTAINER_FORCEINLINE segduo(const segduo &sd) : first(sd.first), second(sd.second) {} }; +template +struct segtrio +{ + T1 first; + T2 second; + T3 third; + + BOOST_CONTAINER_FORCEINLINE segtrio() {} + + template + BOOST_CONTAINER_FORCEINLINE segtrio(const U1 &f, const U2 &s, const U3 &t) + : first(f), second(s), third(t) {} + + template + BOOST_CONTAINER_FORCEINLINE segtrio(const segtrio &sd) + : first(sd.first), second(sd.second), third(sd.third) {} +}; + struct unreachable_sentinel_t { template @@ -233,6 +252,41 @@ struct is_sentinel namespace detail_algo { +////////////////////////////////////////////////////////////////////////////// +// sent_filter: when [first, last) is closed by a true sentinel +// (Sent != Iter), segment walkers cannot decompose Sent and bidirectional +// algorithms cannot step backwards from it; in that case both the iterator +// category and the segmentation tag are downgraded to +// (std::forward_iterator_tag, non_segmented_iterator_tag) so that algorithms +// route through the flat, forward-only path. When Sent == Iter, the +// iterator's natural category and segmentation are preserved. +// +// Used by bidirectional/segmented algorithms (e.g. segmented_partition, +// segmented_find_last_if) that need a single dispatch point covering both +// the (Iter, Iter) and (Iter, Sentinel) call signatures. +////////////////////////////////////////////////////////////////////////////// + +template ::value> +struct sent_filter +{ + typedef std::forward_iterator_tag cat_t; + typedef non_segmented_iterator_tag seg_t; +}; + +template +struct sent_filter +{ + typedef typename boost::container::iterator_traits + ::iterator_category cat_t; + typedef typename segmented_iterator_traits + ::is_segmented_iterator seg_t; +}; + +template +struct sent_filter + : public sent_filter +{}; + // Compile-time metafunction that unwraps a (possibly recursively) segmented // iterator to its deepest non-segmented `local_iterator` type. //