stream: modify read_reminder() to allow custom allocator
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
214e307486
commit
faeddedd46
@ -188,9 +188,10 @@ namespace stdex
|
||||
///
|
||||
/// \return Data read
|
||||
///
|
||||
virtual std::vector<uint8_t> read_remainder(_In_ size_t max_length = SIZE_MAX)
|
||||
template <typename AX = std::allocator<uint8_t>>
|
||||
std::vector<uint8_t, AX> read_remainder(_In_ size_t max_length = SIZE_MAX)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
std::vector<uint8_t, AX> result;
|
||||
size_t offset, length;
|
||||
offset = 0;
|
||||
length = default_block_size;
|
||||
@ -815,10 +816,11 @@ namespace stdex
|
||||
class basic_file : virtual public basic
|
||||
{
|
||||
public:
|
||||
virtual std::vector<uint8_t> read_remainder(_In_ size_t max_length = SIZE_MAX)
|
||||
template <typename AX = std::allocator<uint8_t>>
|
||||
std::vector<uint8_t, AX> read_remainder(_In_ size_t max_length = SIZE_MAX)
|
||||
{
|
||||
size_t length = std::min<size_t>(max_length, static_cast<size_t>(size() - tell()));
|
||||
std::vector<uint8_t> result;
|
||||
std::vector<uint8_t, AX> result;
|
||||
try { result.resize(length); }
|
||||
catch (const std::bad_alloc&) {
|
||||
m_state = state_t::fail;
|
||||
|
Loading…
x
Reference in New Issue
Block a user