diff --git a/include/pocketpy/str.h b/include/pocketpy/str.h index af1dac6e..e303c91f 100644 --- a/include/pocketpy/str.h +++ b/include/pocketpy/str.h @@ -98,7 +98,6 @@ struct StrName { const char* c_str() const; bool empty() const { return index == 0; } - friend std::ostream& operator<<(std::ostream& os, const StrName& sn); Str escape() const; bool operator==(const StrName& other) const noexcept { diff --git a/src/str.cpp b/src/str.cpp index c1cbe5ab..b252b258 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -388,10 +388,6 @@ int utf8len(unsigned char c, bool suppress){ return cnt; } - std::ostream& operator<<(std::ostream& os, const StrName& sn){ - return os << sn.sv(); - } - std::map>& StrName::_interned(){ static std::map> interned; return interned; diff --git a/tests/04_str.py b/tests/04_str.py index 27314b7f..bc820c50 100644 --- a/tests/04_str.py +++ b/tests/04_str.py @@ -180,3 +180,8 @@ assert list(a) == ['测'] assert '\b\b\b' == '\x08\x08\x08' stack=[1,2,3,4]; assert f"{stack[2:]}" == '[3, 4]' + +assert repr('\x1f\x1e\x1f') == '\'\\x1f\\x1e\\x1f\'' + +assert hex(255) == '0xFF' +assert hex(-42) == '-0x2A'