Skip to content

Commit e5a4028

Browse files
committed
Implement BOOST_CONTAINER_DISABLE_SEGMENTED_OUTPUT macro
1 parent 6d26a89 commit e5a4028

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

include/boost/container/experimental/segmented_copy.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,19 @@ SegDstIter segmented_copy_dst_dispatch
184184
//////////////////////////////////////////////////////////////////////////////
185185

186186
template <class SrcIter, class Sent, class OutIter, class Tag, class Cat>
187+
BOOST_CONTAINER_FORCEINLINE
187188
typename algo_enable_if_c<
188189
!Tag::value || is_sentinel<Sent, SrcIter>::value, OutIter>::type
189-
segmented_copy_dispatch(SrcIter first, Sent last, OutIter result, Tag, Cat)
190+
segmented_copy_dispatch(SrcIter first, Sent last, OutIter result, Tag, Cat)
190191
{
192+
#if !defined(BOOST_CONTAINER_DISABLE_SEGMENTED_OUTPUT)
191193
typedef segmented_iterator_traits<OutIter> dst_traits;
192194
return (segmented_copy_dst_dispatch)
193195
(first, last, result, typename dst_traits::is_segmented_iterator(), Cat());
196+
#else
197+
return (segmented_copy_dst_dispatch)
198+
(first, last, result, non_segmented_iterator_tag(), Cat());
199+
#endif
194200
}
195201

196202
template <class SegIter, class OutIter, class Cat>

include/boost/container/experimental/segmented_iterator_traits.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,16 @@ struct is_sentinel<Iter, Iter>
200200
// Force no loop unrolling
201201
#endif
202202

203+
//////////////////////////////////////////////////////////////////////////////
204+
// BOOST_CONTAINER_DISABLE_SEGMENTED_OUTPUT
205+
//
206+
// When defined, segmented algorithms that write to an output iterator will
207+
// NOT exploit segmentation on the output side. Only input (source) iterator
208+
// segmentation is used. This is useful for benchmarking the advantage of
209+
// the segmented output optimisation in isolation.
210+
//
211+
// Define BOOST_CONTAINER_DISABLE_SEGMENTED_OUTPUT before including any
212+
// segmented algorithm header to disable the optimisation.
213+
//////////////////////////////////////////////////////////////////////////////
214+
203215
#endif // BOOST_CONTAINER_EXPERIMENTAL_SEGMENTED_ITERATOR_TRAITS_HPP

include/boost/container/experimental/segmented_remove_copy_if.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,20 @@ SegDstIter segmented_remove_copy_if_dst_dispatch
190190
//////////////////////////////////////////////////////////////////////////////
191191

192192
template <bool Move, class SrcIter, class Sent, class OutIter, class Pred, class Tag, class Cat>
193+
BOOST_CONTAINER_FORCEINLINE
193194
typename algo_enable_if_c<
194195
!Tag::value || is_sentinel<Sent, SrcIter>::value, OutIter>::type
195196
segmented_remove_copy_if_dispatch
196197
(SrcIter first, Sent last, OutIter result, Pred pred, Tag, Cat)
197198
{
199+
#if !defined(BOOST_CONTAINER_DISABLE_SEGMENTED_OUTPUT)
198200
typedef segmented_iterator_traits<OutIter> dst_traits;
199201
return (segmented_remove_copy_if_dst_dispatch<Move>)
200202
(first, last, result, pred, typename dst_traits::is_segmented_iterator(), Cat());
203+
#else
204+
return (segmented_remove_copy_if_dst_dispatch<Move>)
205+
(first, last, result, pred, non_segmented_iterator_tag(), Cat());
206+
#endif
201207
}
202208

203209
template <bool Move, class SegIter, class OutIter, class Pred, class Cat>

0 commit comments

Comments
 (0)