Add flat_static_buffer::reset

This commit is contained in:
Vinnie Falco
2017-08-13 06:48:24 -07:00
parent ad587e11b8
commit 4218a3a972
3 changed files with 30 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
Version 106:
* Dynamic buffer input areas are mutable
* Add flat_static_buffer::reset
--------------------------------------------------------------------------------

View File

@@ -114,6 +114,10 @@ public:
mutable_data_type
mutable_data();
/// Set the input and output sequences to size 0
void
reset();
/** Get a list of buffers that represent the output sequence, with the given size.
@throws std::length_error if the size would exceed the limit
@@ -147,10 +151,10 @@ protected:
/** Constructor
The buffer will be in an undefined state. It is necessary
for the derived class to call @ref reset in order to
initialize the object.
for the derived class to call @ref reset with a pointer
and size in order to initialize the object.
*/
flat_static_buffer_base();
flat_static_buffer_base() = default;
/** Reset the pointed-to buffer.
@@ -175,6 +179,10 @@ private:
return static_cast<std::size_t>(last - first);
}
template<class = void>
void
reset_impl();
template<class = void>
void
reset_impl(void* p, std::size_t n);

View File

@@ -44,6 +44,14 @@ mutable_data() ->
return {in_, dist(in_, out_)};
}
inline
void
flat_static_buffer_base::
reset()
{
reset_impl();
}
inline
auto
flat_static_buffer_base::
@@ -61,6 +69,16 @@ reset(void* p, std::size_t n)
reset_impl(p, n);
}
template<class>
void
flat_static_buffer_base::
reset_impl()
{
in_ = begin_;
out_ = begin_;
last_ = begin_;
}
template<class>
void
flat_static_buffer_base::