Skip to content

Instantly share code, notes, and snippets.

@Aposhian
Created January 11, 2023 20:52
Show Gist options
  • Save Aposhian/a342c361b98f3c75e14ea180b170b761 to your computer and use it in GitHub Desktop.
Save Aposhian/a342c361b98f3c75e14ea180b170b761 to your computer and use it in GitHub Desktop.
Streaming uint8_t pitfall
#include <map>
#include <string>
#include <iostream>
#include <cstdint>
int main() {
std::map<std::string, uint8_t> map{{
{"zero", 0},
{"sixty-five", 65}
}};
for (const auto & [k, v] : map) {
std::cout << "interpreted as char: key=" << k << " value=" << v << std::endl;
std::cout << "interpreted as integer: key=" << k << " value=" << std::to_string(v) << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment