|
| 1 | +#ifndef USE_RANGES_FAKE_STD_H |
| 2 | +#define USE_RANGES_FAKE_STD_H |
| 3 | +namespace std { |
| 4 | + |
| 5 | +template <typename T> class vector { |
| 6 | +public: |
| 7 | + using iterator = T *; |
| 8 | + using const_iterator = const T *; |
| 9 | + using reverse_iterator = T*; |
| 10 | + using reverse_const_iterator = const T*; |
| 11 | + |
| 12 | + constexpr const_iterator begin() const; |
| 13 | + constexpr const_iterator end() const; |
| 14 | + constexpr const_iterator cbegin() const; |
| 15 | + constexpr const_iterator cend() const; |
| 16 | + constexpr iterator begin(); |
| 17 | + constexpr iterator end(); |
| 18 | + constexpr reverse_const_iterator rbegin() const; |
| 19 | + constexpr reverse_const_iterator rend() const; |
| 20 | + constexpr reverse_const_iterator crbegin() const; |
| 21 | + constexpr reverse_const_iterator crend() const; |
| 22 | + constexpr reverse_iterator rbegin(); |
| 23 | + constexpr reverse_iterator rend(); |
| 24 | +}; |
| 25 | + |
| 26 | +template <typename Container> constexpr auto begin(const Container &Cont) { |
| 27 | + return Cont.begin(); |
| 28 | +} |
| 29 | + |
| 30 | +template <typename Container> constexpr auto begin(Container &Cont) { |
| 31 | + return Cont.begin(); |
| 32 | +} |
| 33 | + |
| 34 | +template <typename Container> constexpr auto end(const Container &Cont) { |
| 35 | + return Cont.end(); |
| 36 | +} |
| 37 | + |
| 38 | +template <typename Container> constexpr auto end(Container &Cont) { |
| 39 | + return Cont.end(); |
| 40 | +} |
| 41 | + |
| 42 | +template <typename Container> constexpr auto cbegin(const Container &Cont) { |
| 43 | + return Cont.cbegin(); |
| 44 | +} |
| 45 | + |
| 46 | +template <typename Container> constexpr auto cend(const Container &Cont) { |
| 47 | + return Cont.cend(); |
| 48 | +} |
| 49 | +// Find |
| 50 | +template< class InputIt, class T > |
| 51 | +InputIt find(InputIt first, InputIt last, const T& value); |
| 52 | + |
| 53 | +template <typename Iter> void reverse(Iter begin, Iter end); |
| 54 | + |
| 55 | +template <class InputIt1, class InputIt2> |
| 56 | +bool includes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); |
| 57 | + |
| 58 | +template <class ForwardIt1, class ForwardIt2> |
| 59 | +bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, |
| 60 | + ForwardIt2 last2); |
| 61 | + |
| 62 | +template <class BidirIt> |
| 63 | +bool next_permutation(BidirIt first, BidirIt last); |
| 64 | + |
| 65 | +inline namespace inline_test{ |
| 66 | + |
| 67 | +template <class ForwardIt1, class ForwardIt2> |
| 68 | +bool equal(ForwardIt1 first1, ForwardIt1 last1, |
| 69 | + ForwardIt2 first2, ForwardIt2 last2); |
| 70 | + |
| 71 | +template <class RandomIt> |
| 72 | +void push_heap(RandomIt first, RandomIt last); |
| 73 | + |
| 74 | +template <class InputIt, class OutputIt, class UnaryPred> |
| 75 | +OutputIt copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPred pred); |
| 76 | + |
| 77 | +template <class ForwardIt> |
| 78 | +ForwardIt is_sorted_until(ForwardIt first, ForwardIt last); |
| 79 | + |
| 80 | +template <class InputIt> |
| 81 | +void reduce(InputIt first, InputIt last); |
| 82 | + |
| 83 | +template <class InputIt, class T> |
| 84 | +T reduce(InputIt first, InputIt last, T init); |
| 85 | + |
| 86 | +template <class InputIt, class T, class BinaryOp> |
| 87 | +T reduce(InputIt first, InputIt last, T init, BinaryOp op) { |
| 88 | + // Need a definition to suppress undefined_internal_type when invoked with lambda |
| 89 | + return init; |
| 90 | +} |
| 91 | + |
| 92 | +template <class InputIt, class T> |
| 93 | +T accumulate(InputIt first, InputIt last, T init); |
| 94 | + |
| 95 | +} // namespace inline_test |
| 96 | + |
| 97 | +} // namespace std |
| 98 | + |
| 99 | +#endif // USE_RANGES_FAKE_STD_H |
0 commit comments