Skip to content

Commit

Permalink
Use custom iterator for the ConstantCBS test to get rid of constant e…
Browse files Browse the repository at this point in the history
…lements allocator

Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
  • Loading branch information
Kochin Ivan committed Nov 16, 2021
1 parent a9b1b1d commit c20f6da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions test/common/concepts_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,15 @@ using NoEnd = ContainerBasedSequence</*Begin = */true, /*End = */false>;
template <typename T>
using CustomValueCBS = ContainerBasedSequence</*Begin = */true, /*End = */true, T>;


template <typename T>
struct ConstantAccessCBS {
using iterator = utils::RandomIterator<const T>;
iterator begin() { return nullptr; }
iterator end() { return nullptr; }
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>{}; }
};

struct ForwardIteratorCBS {
Expand Down
4 changes: 2 additions & 2 deletions test/tbb/test_parallel_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void test_psort_cbs_constraints() {
static_assert(!can_call_parallel_sort_with_cbs<NoBegin>);
static_assert(!can_call_parallel_sort_with_cbs<NoEnd>);
static_assert(!can_call_parallel_sort_with_cbs<ForwardIteratorCBS>);
static_assert(!can_call_parallel_sort_with_cbs<ConstantAccessCBS<int>>);
static_assert(!can_call_parallel_sort_with_cbs<ConstantCBS>);
static_assert(!can_call_parallel_sort_with_iterator<CustomValueCBS<NonMovableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<CustomValueCBS<NonMoveAssignableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<CustomValueCBS<NonComparableValue>>);
Expand All @@ -292,7 +292,7 @@ void test_psort_cbs_constraints() {
static_assert(!can_call_parallel_sort_with_cbs_and_compare<NoBegin, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<NoEnd, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<ForwardIteratorCBS, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<ConstantAccessCBS<int>, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<ConstantCBS, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<CustomValueCBS<NonMovableValue>, CompareMovable>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<CustomValueCBS<NonMoveAssignableValue>, CompareMoveAssignable>);
}
Expand Down

0 comments on commit c20f6da

Please sign in to comment.