Skip to content

Commit

Permalink
Disable operator<<() for signed/unsigned char, to catch potential type
Browse files Browse the repository at this point in the history
alias issues with bad int8_t definitions.
  • Loading branch information
zrax committed Jan 28, 2020
1 parent 37139f4 commit da60b25
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/st_stringstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ namespace ST
return append_char(ch);
}

// Some systems alias int8_t as char rather than signed char.
// We don't want to remove the char overload since it's often better
// than streaming a string or calling .append_char(), so instead we
// can disable the use of these overloads on "sane" platforms to
// try to catch their misuse.
// HINT: If you need to stream an int8_t or uint8_t, cast it to
// an int or unsigned int to get the correct behavior...
string_stream &operator<<(signed char) = delete;
string_stream &operator<<(unsigned char) = delete;

string_stream &operator<<(const string &text)
{
return append(text.c_str(), text.size());
Expand Down

0 comments on commit da60b25

Please sign in to comment.