new predefined operations for input ranges (defined for all without need for custom impl)
parent
eb3c273376
commit
d9120a0015
|
@ -850,7 +850,7 @@ struct Function<R(Args...)>: detail::FunctionBase<R, Args...> {
|
|||
ostd::swap(p_call, f.p_call);
|
||||
}
|
||||
|
||||
operator bool() const { return p_call != nullptr; }
|
||||
explicit operator bool() const { return p_call != nullptr; }
|
||||
|
||||
private:
|
||||
detail::FmStorage p_stor;
|
||||
|
|
|
@ -505,6 +505,57 @@ template<typename B, typename C, typename V, typename R = V &,
|
|||
}
|
||||
return (on - n);
|
||||
}
|
||||
|
||||
/* iterator like interface operating on the front part of the range
|
||||
* this is sometimes convenient as it can be used within expressions */
|
||||
|
||||
Reference operator*() const {
|
||||
return ((B *)this)->front();
|
||||
}
|
||||
|
||||
B &operator++() {
|
||||
((B *)this)->pop_front();
|
||||
return *((B *)this);
|
||||
}
|
||||
B operator++(int) {
|
||||
B tmp(*((const B *)this));
|
||||
((B *)this)->pop_front();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
B &operator--() {
|
||||
((B *)this)->push_front();
|
||||
return *((B *)this);
|
||||
}
|
||||
B operator--(int) {
|
||||
B tmp(*((const B *)this));
|
||||
((B *)this)->push_front();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
B operator+(Difference n) const {
|
||||
B tmp(*((const B *)this));
|
||||
tmp.pop_front_n(n);
|
||||
return tmp;
|
||||
}
|
||||
B operator-(Difference n) const {
|
||||
B tmp(*((const B *)this));
|
||||
tmp.push_front_n(n);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
B &operator+=(Difference n) {
|
||||
((B *)this)->pop_front_n(n);
|
||||
return *((B *)this);
|
||||
}
|
||||
B &operator-=(Difference n) {
|
||||
((B *)this)->push_front_n(n);
|
||||
return *((B *)this);
|
||||
}
|
||||
|
||||
/* universal bool operator */
|
||||
|
||||
explicit operator bool() const { return !((B *)this)->empty(); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in New Issue