Skip to content

Commit

Permalink
🐳 chore: make old compilers happy!......
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-qingyu committed May 17, 2024
1 parent b6b7aed commit 5092a80
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions sources/str.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace pyincpp
class Str
{
private:
// Immutable string.
const std::string str_;
// String.
std::string str_;

// Used for FSM.
enum state
Expand Down Expand Up @@ -142,10 +142,7 @@ class Str
Str(const Str& that) = default;

/// Move constructor.
Str(Str&& that)
: str_(std::move(const_cast<std::string&>(that.str_)))
{
}
Str(Str&& that) = default;

/*
* Comparison
Expand All @@ -159,26 +156,10 @@ class Str
*/

/// Copy assignment operator.
Str& operator=(const Str& that)
{
if (this != &that)
{
const_cast<std::string&>(str_) = that.str_;
}

return *this;
}
Str& operator=(const Str& that) = default;

/// Move assignment operator.
Str& operator=(Str&& that)
{
if (this != &that)
{
const_cast<std::string&>(str_) = std::move(const_cast<std::string&>(that.str_));
}

return *this;
}
Str& operator=(Str&& that) = default;

/*
* Iterator
Expand Down

0 comments on commit 5092a80

Please sign in to comment.