Skip to content

can abseil-cpp support AbslStringify for char/unsigned char? #1576

Answered by derekmauro
chenchuanyin asked this question in Q&A
Discussion options

You must be logged in to vote

This is by design because it is potentially error-prone. Sometimes the user may want to print that char, and sometimes the user may want to print the integer value (consider the type alias uint8_t). We decided it is better to be explicit about what it should print:

char x = 120;
absl::StrCat(absl::string_view(&x, 1));  // "x"
absl::StrCat(static_cast<int>(x));  // "120"

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@chenchuanyin
Comment options

@MBkkt
Comment options

Answer selected by derekmauro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants