Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic
diff options
context:
space:
mode:
1 files changed, 9 insertions, 9 deletions
-rw-r--r--src/Generic/List/List.hpp18
diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp
index d4385e2..b4c3b73 100644
--- a/src/Generic/List/List.hpp
+++ b/src/Generic/List/List.hpp
@@ -40,9 +40,6 @@ public:
List(List&& other);
List& operator=(List&& other);
-
- friend std::istream& operator>>(std::istream& istr, List<T>& obj);
- friend std::ostream& operator<<(std::ostream& ostr, const List<T>& obj);
};
template <typename T>
@@ -234,19 +231,22 @@ List<T>& List<T>::operator=(List&& other) {
template <typename T>
std::istream& operator>>(std::istream& istr, List<T>& obj) {
- istr >> obj.length >> obj.count;
-
- delete[] obj.elements;
- obj.elements = new T[obj.length];
+ List<T> newObj;
+ unsigned count;
+ istr >> count;
- for (int i = 0; i < obj.count; i++)
- istr >> obj.elements[i];
+ T temp;
+ for (int i = 0; i < count; i++) {
+ istr >> temp;
+ obj.add(temp);
+ }
return istr;
}
template <typename T>
std::ostream& operator<<(std::ostream& ostr, const List<T>& obj) {
+ ostr << obj.get_count() << " ";
for (int i = 0; i < obj.count; i++)
ostr << obj.elements[i];