1 #ifndef PYTHONIC_BUILTIN_REVERSED_HPP
2 #define PYTHONIC_BUILTIN_REVERSED_HPP
3 
4 #include "pythonic/include/builtins/reversed.hpp"
5 
6 #include "pythonic/utils/functor.hpp"
7 
8 PYTHONIC_NS_BEGIN
9 
10 namespace builtins
11 {
12   namespace details
13   {
14 
15     template <class Iterable>
reversed()16     reversed<Iterable>::reversed()
17     {
18     }
19 
20     template <class Iterable>
reversed(Iterable const & iterable)21     reversed<Iterable>::reversed(Iterable const &iterable)
22         : iterable(iterable)
23     {
24     }
25 
26     template <class Iterable>
begin()27     typename reversed<Iterable>::iterator reversed<Iterable>::begin()
28     {
29       return iterable.rbegin();
30     }
31 
32     template <class Iterable>
end()33     typename reversed<Iterable>::iterator reversed<Iterable>::end()
34     {
35       return iterable.rend();
36     }
37 
38     template <class Iterable>
39     typename reversed<Iterable>::const_iterator
begin() const40     reversed<Iterable>::begin() const
41     {
42       return iterable.rbegin();
43     }
44 
45     template <class Iterable>
end() const46     typename reversed<Iterable>::const_iterator reversed<Iterable>::end() const
47     {
48       return iterable.rend();
49     }
50   }
51 
52   template <class Iterable>
reversed(Iterable const & iterable)53   details::reversed<Iterable> reversed(Iterable const &iterable)
54   {
55     return {iterable};
56   }
57 }
58 PYTHONIC_NS_END
59 
60 #endif
61