@@ -14,21 +14,21 @@ namespace iter {
1414 template <typename Container>
1515 using OptIterDeref = boost::optional<iterator_deref<Container>>;
1616
17- template <typename Container, typename ... RestContainers>
17+ template <typename ... RestContainers>
1818 class ZippedLongest ;
1919
2020 template <typename ... Containers>
2121 ZippedLongest<Containers...> zip_longest (Containers&&...);
2222
2323 template <typename Container, typename ... RestContainers>
24- class ZippedLongest {
24+ class ZippedLongest <Container, RestContainers...> {
2525 static_assert (!std::is_rvalue_reference<Container>::value,
2626 " Itertools cannot be templated with rvalue references" );
2727
2828 friend ZippedLongest zip_longest<Container, RestContainers...>(
2929 Container&&, RestContainers&&...);
3030
31- template <typename C, typename ... RC >
31+ template <typename ... Cs >
3232 friend class ZippedLongest ;
3333
3434 private:
@@ -115,78 +115,40 @@ namespace iter {
115115 };
116116
117117
118- template <typename Container>
119- class ZippedLongest <Container> {
120- static_assert (!std::is_rvalue_reference<Container>::value,
121- " Itertools cannot be templated with rvalue references" );
122-
123- friend ZippedLongest zip_longest<Container>(Container&&);
124-
125- template <typename C, typename ... RC >
126- friend class ZippedLongest ;
127-
128- private:
129- using OptType = OptIterDeref<Container>;
130-
131- Container container;
132- ZippedLongest (Container container)
133- : container(std::forward<Container>(container))
134- { }
135-
118+ template <>
119+ class ZippedLongest <> {
136120 public:
137-
138121 class Iterator
139- : public std::iterator<std::input_iterator_tag,
140- std::tuple<OptType>>
122+ : public std::iterator<std::input_iterator_tag, std::tuple<>>
141123 {
142- private:
143- iterator_type<Container> iter;
144- iterator_type<Container> end;
145124 public:
146- Iterator (
147- iterator_type<Container> it,
148- iterator_type<Container> in_end)
149- : iter{it},
150- end{in_end}
151- { }
152-
153125 Iterator& operator ++() {
154- if (this ->iter != this ->end ) {
155- ++this ->iter ;
156- }
157126 return *this ;
158127 }
159128
160- Iterator operator ++(int ) {
161- auto ret = *this ;
162- ++*this ;
163- return ret;
129+ constexpr Iterator operator ++(int ) {
130+ return *this ;
164131 }
165132
166- bool operator !=(const Iterator& other ) const {
167- return this -> iter != other. iter ;
133+ constexpr bool operator !=(const Iterator&) const {
134+ return false ;
168135 }
169136
170- bool operator ==(const Iterator& other ) const {
171- return !(* this != other) ;
137+ constexpr bool operator ==(const Iterator&) const {
138+ return true ;
172139 }
173140
174- std::tuple<OptType> operator *() {
175- if (this ->iter != this ->end ) {
176- return std::tuple<OptType>{{*this ->iter }};
177- }
178- return std::tuple<OptType>{{}};
141+ constexpr std::tuple<> operator *() {
142+ return {};
179143 }
180144 };
181145
182- Iterator begin () {
183- return {std::begin (this ->container ),
184- std::end (this ->container )};
146+ constexpr Iterator begin () {
147+ return {};
185148 }
186149
187- Iterator end () {
188- return {std::end (this ->container ),
189- std::end (this ->container )};
150+ constexpr Iterator end () {
151+ return {};
190152 }
191153 };
192154
0 commit comments