+/// The MoveList struct is a simple wrapper around generate(), sometimes comes
+/// handy to use this class instead of the low level generate() function.
+template<GenType T>
+struct MoveList {
+
+ explicit MoveList(const Position& pos) : cur(mlist), last(generate<T>(pos, mlist)) {}
+ void operator++() { cur++; }
+ bool end() const { return cur == last; }
+ Move move() const { return cur->move; }
+ size_t size() const { return last - mlist; }
+ bool contains(Move m) const {
+ for (const MoveStack* it(mlist); it != last; ++it) if (it->move == m) return true;
+ return false;
+ }
+
+private:
+ MoveStack mlist[MAX_MOVES];
+ MoveStack *cur, *last;
+};
+