Skip to content

Commit 5c040a1

Browse files
feat: add pad parameter to set padding value
1 parent 2a7c9e8 commit 5c040a1

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

include/BufferStream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ class BufferStream {
294294
}
295295

296296
template<BufferStreamPODType T = std::byte>
297-
BufferStream& pad(std::uint64_t n = 1) {
298-
for (std::uint64_t i = 0; i < n * sizeof(T); i++) {
299-
this->write<std::byte>({});
297+
BufferStream& pad(std::uint64_t n = 1, T value = {}) {
298+
for (std::uint64_t i = 0; i < n; i++) {
299+
this->write<T>(value);
300300
}
301301
return *this;
302302
}

include/FileStream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ class FileStream {
235235
}
236236

237237
template<BufferStreamPODType T = std::byte>
238-
FileStream& pad(std::uint64_t n = 1) {
239-
for (std::uint64_t i = 0; i < n * sizeof(T); i++) {
240-
this->write<std::byte>({});
238+
FileStream& pad(std::uint64_t n = 1, T value = {}) {
239+
for (std::uint64_t i = 0; i < n; i++) {
240+
this->write<T>(value);
241241
}
242242
return *this;
243243
}

0 commit comments

Comments
 (0)