diff options
author | Michael Jones <jonesmz@jonesmz.com> | 2018-04-06 01:13:04 (GMT) |
---|---|---|
committer | Michael Jones <jonesmz@jonesmz.com> | 2020-09-30 21:19:11 (GMT) |
commit | a5aae85a3c8a4032ab18b82afe6c77673125d888 (patch) | |
tree | 0a2a857d7c717d15d4d1cf04b3cab414b9e52f21 /src/string_piece.h | |
parent | ff4f2a0db21b738bba743ad543d8553417aca7b0 (diff) | |
download | Ninja-a5aae85a3c8a4032ab18b82afe6c77673125d888.zip Ninja-a5aae85a3c8a4032ab18b82afe6c77673125d888.tar.gz Ninja-a5aae85a3c8a4032ab18b82afe6c77673125d888.tar.bz2 |
Remove 'using namespace std' from header files, properly namespace all std symbols
Diffstat (limited to 'src/string_piece.h')
-rw-r--r-- | src/string_piece.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/string_piece.h b/src/string_piece.h index 031bda4..1c0bee6 100644 --- a/src/string_piece.h +++ b/src/string_piece.h @@ -17,8 +17,6 @@ #include <string> -using namespace std; - #include <string.h> /// StringPiece represents a slice of a string whose memory is managed @@ -30,7 +28,7 @@ struct StringPiece { StringPiece() : str_(NULL), len_(0) {} /// The constructors intentionally allow for implicit conversions. - StringPiece(const string& str) : str_(str.data()), len_(str.size()) {} + StringPiece(const std::string& str) : str_(str.data()), len_(str.size()) {} StringPiece(const char* str) : str_(str), len_(strlen(str)) {} StringPiece(const char* str, size_t len) : str_(str), len_(len) {} @@ -38,14 +36,15 @@ struct StringPiece { bool operator==(const StringPiece& other) const { return len_ == other.len_ && memcmp(str_, other.str_, len_) == 0; } + bool operator!=(const StringPiece& other) const { return !(*this == other); } /// Convert the slice into a full-fledged std::string, copying the /// data into a new string. - string AsString() const { - return len_ ? string(str_, len_) : string(); + std::string AsString() const { + return len_ ? std::string(str_, len_) : std::string(); } const_iterator begin() const { |