Skip to content

Commit

Permalink
Use custom constant iterator to get rid of forbidden constant allocator
Browse files Browse the repository at this point in the history
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
  • Loading branch information
Kochin Ivan committed Nov 16, 2021
1 parent c20f6da commit 50c4fdd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions test/common/concepts_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ namespace parallel_sort_value {
using NonMoveAssignableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */false, /*ComparableV = */true>;
using NonComparableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */true, /*ComparableV = */false>;
} // namespace parallel_sort_value
template <typename T>
class ConstantIT {
T data{};
const T& operator* () const { return data; }
};
namespace container_based_sequence {

template <bool EnableBegin, bool EnableEnd, typename T = int>
Expand All @@ -272,12 +277,6 @@ using NoEnd = ContainerBasedSequence</*Begin = */true, /*End = */false>;
template <typename T>
using CustomValueCBS = ContainerBasedSequence</*Begin = */true, /*End = */true, T>;

template <typename T>
class ConstantIT {
T data{};
const T& operator* () const { return data; }
};

struct ConstantCBS {
ConstantIT<int> begin() const { return ConstantIT<int>{}; }
ConstantIT<int> end() const { return ConstantIT<int>{}; }
Expand Down
2 changes: 1 addition & 1 deletion test/tbb/test_parallel_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ void test_psort_iterator_constraints() {
static_assert(can_call_parallel_sort_with_iterator<typename std::vector<int>::iterator>);
static_assert(!can_call_parallel_sort_with_iterator<utils::ForwardIterator<int>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::InputIterator<int>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<const int>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<NonMovableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<NonMoveAssignableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<NonComparableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<ConstantIT<int>>);

static_assert(can_call_parallel_sort_with_iterator_and_compare<utils::RandomIterator<int>, CorrectCompare<int>>);
static_assert(can_call_parallel_sort_with_iterator_and_compare<typename std::vector<int>::iterator, CorrectCompare<int>>);
Expand Down

0 comments on commit 50c4fdd

Please sign in to comment.