Skip to content

Commit 987cabb

Browse files
committed
arrayview: corrected operator<< to right-align small hex values
1 parent 116c939 commit 987cabb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arrayview.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#pragma once
2+
3+
#include <iomanip>
24
/*
35
* like string_view, but takes an iterator-pair.
6+
*
7+
* Note that array_view can also take streampos as 'P', and therefore I did not
8+
* add operator[] and value_type.
49
*/
510
template<typename P>
611
class array_view {
@@ -84,8 +89,9 @@ std::ostream& operator<<(std::ostream&os, const array_view<P>& buf)
8489
for (const auto& b : buf) {
8590
os.copyfmt(state);
8691
if (!first && fillchar) os << fillchar;
87-
os.fill('0');
88-
os.width(2);
92+
os << std::right;
93+
os << std::setfill('0');
94+
os << std::setw(2);
8995
os << std::hex << unsigned(b);
9096
first= false;
9197
}

0 commit comments

Comments
 (0)