Skip to content

Commit

Permalink
I prefer 8 bit integers printing as integers instead of chars
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Feb 18, 2024
1 parent 19ac190 commit 57a4fe3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/Containers/TinyVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <algorithm>
#include <cstddef>
#include <initializer_list>
#include <iostream>
#include <limits>

namespace poly::containers {
Expand Down Expand Up @@ -98,9 +97,15 @@ template <class T, size_t N, typename L = ptrdiff_t> class TinyVector {
friend inline auto operator<<(std::ostream &os, const TinyVector &x)
-> std::ostream & {
os << "[";
if (!x.empty()) os << x[0];
for (L i = 1; i < x.size(); ++i) os << ", " << x[i];
if constexpr (std::same_as<T, int8_t> || std::same_as<T, uint8_t>) {
if (!x.empty()) os << x[0];
for (L i = 1; i < x.size(); ++i) os << ", " << x[i];
} else {
if (!x.empty()) os << x[0];
for (L i = 1; i < x.size(); ++i) os << ", " << x[i];
}
return os << "]";
}
};
} // namespace poly::containers

0 comments on commit 57a4fe3

Please sign in to comment.