Made error message more comprehensible.
[oota-llvm.git] / include / Support / iterator
1 //===-- Support/iterator - "Portable" wrapper around <iterator> -*- C++ -*-===//
2 //
3 // This file provides a wrapper around the mysterious <iterator> header file.
4 // In GCC 2.95.3, the file defines a bidirectional_iterator class (and other
5 // friends), instead of the standard iterator class.  In GCC 3.1, the
6 // bidirectional_iterator class got moved out and the new, standards compliant,
7 // iterator<> class was added.  Because there is nothing that we can do to get
8 // correct behavior on both compilers, we have this header with #ifdef's.  Gross
9 // huh?
10 //
11 // By #includ'ing this file, you get the contents of <iterator> plus the
12 // following classes in the global namespace:
13 //
14 //   1. bidirectional_iterator
15 //   2. forward_iterator
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef SUPPORT_ITERATOR
20 #define SUPPORT_ITERATOR
21
22 #include "Config/config.h"
23
24 #include <iterator>
25
26 //////////////////////////////////////////////////////////////////////////////
27 // If the bidirectional iterator is not defined, attempt to define it using
28 // the C++ standard iterator.
29 //////////////////////////////////////////////////////////////////////////////
30 #ifndef HAVE_BI_ITERATOR
31 #ifdef HAVE_STD_ITERATOR
32
33 // Define stupid wrappers around std::iterator...
34 template<class Ty, class PtrDiffTy>
35 struct bidirectional_iterator
36   : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> {
37 };
38
39 #else
40 #error "Need to have standard iterator to define bidirectional iterator!"
41 #endif
42
43 #else
44
45 // Just use bidirectional_iterator directly.
46 using std::bidirectional_iterator;
47
48 #endif
49
50 //////////////////////////////////////////////////////////////////////////////
51 // If the forward iterator is not defined, attempt to define it using the
52 // C++ standard iterator.
53 //////////////////////////////////////////////////////////////////////////////
54 #ifndef HAVE_FWD_ITERATOR
55 #ifdef HAVE_STD_ITERATOR
56 template<class Ty, class PtrDiffTy>
57 struct forward_iterator
58   : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> {
59 };
60 #else
61 #error "Need to have standard iterator to define forward iterator!"
62 #endif
63 #else
64 // Just use forward iterator directly.
65 using std::forward_iterator;
66 #endif
67
68
69 #endif