#ifndef Rice_Iterator__ipp_ #define Rice_Iterator__ipp_ #include #include #include "../Data_Object_defn.hpp" #include "method_data.hpp" namespace Rice::detail { template inline Iterator:: Iterator(Iterator_T(T::* begin)(), Iterator_T(T::* end)()) : begin_(begin), end_(end) { } template inline VALUE Iterator:: call(VALUE self) { using Iter_T = Iterator; Iter_T* iterator = detail::MethodData::data(); return iterator->operator()(self); } template inline VALUE Iterator:: operator()(VALUE self) { using Value_T = typename std::iterator_traits::value_type; Data_Object obj(self); Iterator_T it = std::invoke(this->begin_, *obj); Iterator_T end = std::invoke(this->end_, *obj); for (; it != end; ++it) { protect(rb_yield, detail::To_Ruby().convert(*it)); } return self; } } #endif // Rice_Iterator__ipp_