brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 7c3e39d Raw
100 lines · c
1#ifndef USE_RANGES_FAKE_STD_H2#define USE_RANGES_FAKE_STD_H3namespace std {4 5template <typename T> class vector {6public: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 26template <typename Container> constexpr auto begin(const Container &Cont) {27  return Cont.begin();28}29 30template <typename Container> constexpr auto begin(Container &Cont) {31  return Cont.begin();32}33 34template <typename Container> constexpr auto end(const Container &Cont) {35  return Cont.end();36}37 38template <typename Container> constexpr auto end(Container &Cont) {39  return Cont.end();40}41 42template <typename Container> constexpr auto cbegin(const Container &Cont) {43  return Cont.cbegin();44}45 46template <typename Container> constexpr auto cend(const Container &Cont) {47  return Cont.cend();48}49// Find50template< class InputIt, class T >51InputIt find(InputIt first, InputIt last, const T& value);52 53template <typename Iter> void reverse(Iter begin, Iter end);54 55template <class InputIt1, class InputIt2>56bool includes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2);57 58template <class ForwardIt1, class ForwardIt2>59bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,60                    ForwardIt2 last2);61 62template <class BidirIt>63bool next_permutation(BidirIt first, BidirIt last);64 65inline namespace inline_test{66 67template <class ForwardIt1, class ForwardIt2>68bool equal(ForwardIt1 first1, ForwardIt1 last1,69           ForwardIt2 first2, ForwardIt2 last2);70 71template <class RandomIt>72void push_heap(RandomIt first, RandomIt last);73 74template <class InputIt, class OutputIt, class UnaryPred>75OutputIt copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPred pred);76 77template <class ForwardIt>78ForwardIt is_sorted_until(ForwardIt first, ForwardIt last);79 80template <class InputIt>81void reduce(InputIt first, InputIt last);82 83template <class InputIt, class T>84T reduce(InputIt first, InputIt last, T init);85 86template <class InputIt, class T, class BinaryOp>87T reduce(InputIt first, InputIt last, T init, BinaryOp op) {88  // Need a definition to suppress undefined_internal_type when invoked with lambda89  return init;90}91 92template <class InputIt, class T>93T accumulate(InputIt first, InputIt last, T init);94 95} // namespace inline_test96 97} // namespace std98 99#endif // USE_RANGES_FAKE_STD_H100