summaryrefslogtreecommitdiffstats
path: root/include/Support/iterator
blob: 96ea7781ce2bdfe1ec99c03526b1da6035ae4c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//===-- Support/iterator - "Portable" wrapper around <iterator> -*- C++ -*-===//
//
// This file provides a wrapper around the mysterious <iterator> header file.
// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other
// friends), instead of the standard iterator class.  In GCC 3.1, the
// bidirectional_iterator class got moved out and the new, standards compliant,
// iterator<> class was added.  Because there is nothing that we can do to get
// correct behavior on both compilers, we have this header with #ifdef's.  Gross
// huh?
//
// By #includ'ing this file, you get the contents of <iterator> plus the
// following classes in the global namespace:
//
//   1. bidirectional_iterator
//   2. forward_iterator
//
//===----------------------------------------------------------------------===//

#ifndef SUPPORT_ITERATOR
#define SUPPORT_ITERATOR

#include "Config/config.h"

#include <iterator>

//////////////////////////////////////////////////////////////////////////////
// If the bidirectional iterator is not defined, attempt to define it using
// the C++ standard iterator.
//////////////////////////////////////////////////////////////////////////////
#ifndef HAVE_BI_ITERATOR
#ifdef HAVE_STD_ITERATOR

// Define stupid wrappers around std::iterator...
template<class Ty, class PtrDiffTy>
struct bidirectional_iterator
  : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> {
};

#else
#error "Need to have standard iterator to define bidirectional iterator!"
#endif

#else

// Just use bidirectional_iterator directly.
using std::bidirectional_iterator;

#endif

//////////////////////////////////////////////////////////////////////////////
// If the forward iterator is not defined, attempt to define it using the
// C++ standard iterator.
//////////////////////////////////////////////////////////////////////////////
#ifndef HAVE_FWD_ITERATOR
#ifdef HAVE_STD_ITERATOR
template<class Ty, class PtrDiffTy>
struct forward_iterator
  : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> {
};
#else
#error "Need to have standard iterator to define forward iterator!"
#endif
#else
// Just use forward iterator directly.
using std::forward_iterator;
#endif


#endif