Created
January 11, 2023 20:52
-
-
Save Aposhian/a342c361b98f3c75e14ea180b170b761 to your computer and use it in GitHub Desktop.
Streaming uint8_t pitfall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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