Skip to content

Commit 0cde291

Browse files
committed
imap iter inherits from std::iterator
1 parent 1cb217c commit 0cde291

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

imap.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ namespace iter {
7878
private:
7979
MapFunc map_func;
8080
ZippedType zipped;
81+
82+
using IMapIterDeref = decltype(detail::call_with_tuple(
83+
map_func, *std::begin(zipped)));
8184

8285
// Value constructor for use only in the imap function
8386
IMap(MapFunc map_func, Containers&& ... containers) :
@@ -91,7 +94,9 @@ namespace iter {
9194
IMap(const IMap&) = default;
9295
IMap(IMap&&) = default;
9396

94-
class Iterator {
97+
class Iterator
98+
: public std::iterator<std::input_iterator_tag, IMapIterDeref>
99+
{
95100
private:
96101
MapFunc map_func;
97102
ZippedIterType zipiter;
@@ -102,10 +107,7 @@ namespace iter {
102107
zipiter(zipiter)
103108
{ }
104109

105-
auto operator*() ->
106-
decltype(detail::call_with_tuple(
107-
this->map_func, *(this->zipiter)))
108-
{
110+
IMapIterDeref operator*() {
109111
return detail::call_with_tuple(
110112
this->map_func, *(this->zipiter));
111113
}

0 commit comments

Comments
 (0)