Open heheda123123 opened 1 week ago
if i use below code
#include <iostream> #include <vector> #include <iomanip> // For std::hex and std::setw std::ostream& operator<<(std::ostream& out, const std::vector<uint8_t>& v) { for (const auto& val : v) { // Output each value in hexadecimal format, padded with zeros to 2 digits out << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(val) << " "; } return out; } int main() { std::vector<uint8_t> aa {1,2,3}; std::cout << aa; return 0; }
output is
01 02 03
if I use dbg-macro, the output is
#include <iostream> #include <vector> #include <iomanip> // For std::hex and std::setw #include <dbg.h> std::ostream& operator<<(std::ostream& out, const std::vector<uint8_t>& v) { for (const auto& val : v) { // Output each value in hexadecimal format, padded with zeros to 2 digits out << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(val) << " "; } return out; } int main() { std::vector<uint8_t> aa {1,2,3}; dbg(aa); return 0; }
[src\main.cpp:19 (main)] aa = {, , } (std::vector<uint8_t>)
can use this method
dbg(std::vector<uint32_t> (aa.begin(), aa.end()));
Thank you for reporting this. I'll actually reopen this. Would be great if we could support this out-of the box.
if i use below code
output is
if I use dbg-macro, the output is