Skip to content

Commit 94d6585

Browse files
committed
avoid using std::iterator
1 parent 60406d2 commit 94d6585

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

src/tbb/include/tbb/compat/iterator.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
#ifndef TBB_COMPAT_ITERATOR_H
3+
#define TBB_COMPAT_ITERATOR_H
4+
5+
#include <cstddef>
6+
7+
#include <iterator>
8+
9+
namespace tbb {
10+
11+
template <
12+
typename Category,
13+
typename T,
14+
typename Distance = std::ptrdiff_t,
15+
typename Pointer = T*,
16+
typename Reference = T&
17+
> struct iterator
18+
{
19+
using iterator_category = Category;
20+
using value_type = T;
21+
using difference_type = Distance;
22+
using pointer = Pointer;
23+
using reference = Reference;
24+
};
25+
26+
} // end namespace tbb
27+
28+
#endif
29+

src/tbb/include/tbb/concurrent_hash_map.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <cstring> // Need std::memset
2424
#include __TBB_STD_SWAP_HEADER
2525

26+
#include "compat/iterator.h"
2627
#include "tbb_allocator.h"
2728
#include "spin_rw_mutex.h"
2829
#include "atomic.h"
@@ -340,7 +341,7 @@ namespace interface5 {
340341
@ingroup containers */
341342
template<typename Container, typename Value>
342343
class hash_map_iterator
343-
: public std::iterator<std::forward_iterator_tag,Value>
344+
: public tbb::iterator<std::forward_iterator_tag,Value>
344345
{
345346
typedef Container map_type;
346347
typedef typename Container::node node;

src/tbb/include/tbb/enumerable_thread_specific.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef __TBB_enumerable_thread_specific_H
1818
#define __TBB_enumerable_thread_specific_H
1919

20+
#include "compat/iterator.h"
21+
2022
#include "atomic.h"
2123
#include "concurrent_vector.h"
2224
#include "tbb_thread.h"
@@ -296,7 +298,7 @@ namespace interface6 {
296298
class enumerable_thread_specific_iterator
297299
#if defined(_WIN64) && defined(_MSC_VER)
298300
// Ensure that Microsoft's internal template function _Val_type works correctly.
299-
: public std::iterator<std::random_access_iterator_tag,Value>
301+
: public tbb::iterator<std::random_access_iterator_tag,Value>
300302
#endif /* defined(_WIN64) && defined(_MSC_VER) */
301303
{
302304
//! current position in the concurrent_vector
@@ -458,7 +460,7 @@ namespace interface6 {
458460
template<typename SegmentedContainer, typename Value >
459461
class segmented_iterator
460462
#if defined(_WIN64) && defined(_MSC_VER)
461-
: public std::iterator<std::input_iterator_tag, Value>
463+
: public tbb::iterator<std::input_iterator_tag, Value>
462464
#endif
463465
{
464466
template<typename C, typename T, typename U>

src/tbb/include/tbb/internal/_concurrent_queue_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#error Do not #include this internal file directly; use public TBB headers instead.
2222
#endif
2323

24+
#include "../compat/iterator.h"
25+
2426
#include "../tbb_stddef.h"
2527
#include "../tbb_machine.h"
2628
#include "../atomic.h"
@@ -741,7 +743,7 @@ template<typename T> struct tbb_remove_cv<const volatile T> {typedef T type;};
741743
@ingroup containers */
742744
template<typename Container, typename Value>
743745
class concurrent_queue_iterator: public concurrent_queue_iterator_base_v3<typename tbb_remove_cv<Value>::type>,
744-
public std::iterator<std::forward_iterator_tag,Value> {
746+
public tbb::iterator<std::forward_iterator_tag,Value> {
745747
#if !__TBB_TEMPLATE_FRIENDS_BROKEN
746748
template<typename T, class A>
747749
friend class ::tbb::strict_ppl::concurrent_queue;
@@ -1000,7 +1002,7 @@ typedef concurrent_queue_iterator_base_v3 concurrent_queue_iterator_base;
10001002
@ingroup containers */
10011003
template<typename Container, typename Value>
10021004
class concurrent_queue_iterator: public concurrent_queue_iterator_base,
1003-
public std::iterator<std::forward_iterator_tag,Value> {
1005+
public tbb::iterator<std::forward_iterator_tag,Value> {
10041006

10051007
#if !__TBB_TEMPLATE_FRIENDS_BROKEN
10061008
template<typename T, class A>

src/tbb/include/tbb/internal/_concurrent_unordered_impl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <cstring> // Need std::memset
3333
#include __TBB_STD_SWAP_HEADER
3434

35+
#include "../compat/iterator.h"
36+
3537
#include "../atomic.h"
3638
#include "../tbb_exception.h"
3739
#include "../tbb_allocator.h"
@@ -64,7 +66,7 @@ class concurrent_unordered_base;
6466

6567
// Forward list iterators (without skipping dummy elements)
6668
template<class Solist, typename Value>
67-
class flist_iterator : public std::iterator<std::forward_iterator_tag, Value>
69+
class flist_iterator : public tbb::iterator<std::forward_iterator_tag, Value>
6870
{
6971
template <typename T, typename Allocator>
7072
friend class split_ordered_list;

src/tbb/src/test/test_container_move_support.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "harness_allocator.h"
2323
#include "harness_state_trackable.h"
2424

25+
#include "tbb/compat/iterator.h"
26+
2527
#include "tbb/atomic.h"
2628
#include "tbb/aligned_space.h"
2729
#include "tbb/internal/_allocator_traits.h"
@@ -172,7 +174,7 @@ class FooIteratorBase {
172174
friend bool operator!=(const FooIteratorType & lhs, const FooIteratorType & rhs){ return !(lhs == rhs); }
173175
};
174176

175-
class FooIterator: public std::iterator<std::input_iterator_tag,FooWithAssign>, public FooIteratorBase<FooIterator> {
177+
class FooIterator: public tbb::iterator<std::input_iterator_tag,FooWithAssign>, public FooIteratorBase<FooIterator> {
176178
public:
177179
FooIterator(intptr_t x): FooIteratorBase<FooIterator>(x) {}
178180

@@ -181,7 +183,7 @@ class FooIterator: public std::iterator<std::input_iterator_tag,FooWithAssign>,
181183
}
182184
};
183185

184-
class FooPairIterator: public std::iterator<std::input_iterator_tag, std::pair<FooWithAssign,FooWithAssign> >, public FooIteratorBase<FooPairIterator> {
186+
class FooPairIterator: public tbb::iterator<std::input_iterator_tag, std::pair<FooWithAssign,FooWithAssign> >, public FooIteratorBase<FooPairIterator> {
185187
public:
186188
FooPairIterator(intptr_t x): FooIteratorBase<FooPairIterator>(x) {}
187189

0 commit comments

Comments
 (0)