diff options
Diffstat (limited to 'include/vector2.hpp')
-rw-r--r-- | include/vector2.hpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/vector2.hpp b/include/vector2.hpp index 77ee7e7..5c9f9e1 100644 --- a/include/vector2.hpp +++ b/include/vector2.hpp @@ -24,9 +24,13 @@ struct vector2 { } vector2<T>& operator=(const std::string& s) { - auto comma = s.find(','); - x = std::stoi(s.substr(0, comma)); - y = std::stoi(s.substr(comma + 1)); + if (s.empty()) { + x = y = 0; + } else { + auto comma = s.find(','); + x = std::stoi(s.substr(0, comma)); + y = std::stoi(s.substr(comma + 1)); + } return *this; } |