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: Version 106:
* Dynamic buffer input areas are mutable * Dynamic buffer input areas are mutable
* Add flat_static_buffer::reset
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

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

View File

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