forked from OctaForge/libostd
get_n is now called copy (and doesn't modify itself unless it's InputRange)
This commit is contained in:
parent
dd157f8be8
commit
e6e1020702
|
@ -463,8 +463,8 @@ template<typename B, typename C, typename V, typename R = V &,
|
|||
|
||||
template<typename OR,
|
||||
typename = octa::EnableIf<octa::IsOutputRange<OR>::value
|
||||
>> Size get_n(OR orange, Size n = -1) {
|
||||
B &r = *((B *)this);
|
||||
>> Size copy(OR orange, Size n = -1) {
|
||||
B r(*((B *)this));
|
||||
Size on = n;
|
||||
for (; n && !r.empty(); --n) {
|
||||
orange.put(r.front());
|
||||
|
@ -473,8 +473,8 @@ template<typename B, typename C, typename V, typename R = V &,
|
|||
return (on - n);
|
||||
}
|
||||
|
||||
Size get_n(octa::RemoveCv<Value> *p, Size n = -1) {
|
||||
B &r = *((B *)this);
|
||||
Size copy(octa::RemoveCv<Value> *p, Size n = -1) {
|
||||
B r(*((B *)this));
|
||||
Size on = n;
|
||||
for (; n && !r.empty(); --n) {
|
||||
*p++ = r.front();
|
||||
|
@ -910,16 +910,16 @@ struct PointerRange: InputRange<PointerRange<T>, FiniteRandomAccessRangeTag, T>
|
|||
|
||||
template<typename R,
|
||||
typename = octa::EnableIf<octa::IsOutputRange<R>::value
|
||||
>> octa::Size get_n(R orange, octa::Size n = -1) {
|
||||
>> octa::Size copy(R orange, octa::Size n = -1) {
|
||||
octa::Size c = size();
|
||||
if (n < c) c = n;
|
||||
return orange.put_n(p_beg, c);
|
||||
}
|
||||
|
||||
octa::Size get_n(octa::RemoveCv<T> *p, octa::Size n = -1) {
|
||||
octa::Size copy(octa::RemoveCv<T> *p, octa::Size n = -1) {
|
||||
octa::Size c = size();
|
||||
if (n < c) c = n;
|
||||
return get_n(PointerRange(p, c), c);
|
||||
return copy(PointerRange(p, c), c);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -214,7 +214,7 @@ struct StreamRange<T, true>: InputRange<
|
|||
return p_stream->put(p, n);
|
||||
}
|
||||
|
||||
octa::Size get_n(octa::RemoveCv<T> *p, octa::Size n = -1) {
|
||||
octa::Size copy(octa::RemoveCv<T> *p, octa::Size n = -1) {
|
||||
if (n == octa::Size(-1)) {
|
||||
n = p_stream->size() / sizeof(T);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class Vector {
|
|||
octa::RangeSize<R> l = range.size();
|
||||
reserve(l);
|
||||
p_len = l;
|
||||
range.get_n(p_buf.first(), l);
|
||||
range.copy(p_buf.first(), l);
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
|
|
Loading…
Reference in a new issue