Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic
diff options
context:
space:
mode:
Commite3883be7106e667322d51e35aa124ee7298125cb (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 16:08:36 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 16:08:36 +0300
Files90e06f660d37607494d38658e284de88e4d9b050 /src/Generic
FMI-OOP-P1_TicketSystem-e3883be7106e667322d51e35aa124ee7298125cb.tar
FMI-OOP-P1_TicketSystem-e3883be7106e667322d51e35aa124ee7298125cb.tar.gz
FMI-OOP-P1_TicketSystem-e3883be7106e667322d51e35aa124ee7298125cb.zip
Parent4c1f8f7c13f22fc701206ea56dae30d26aca9bda (diff)
Autocommit at 07.05.2022 @ 16:08
1 files changed, 32 insertions, 28 deletions
-rw-r--r--src/Generic/List/List.hpp60
diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp
index 2569380..7bbc835 100644
--- a/src/Generic/List/List.hpp
+++ b/src/Generic/List/List.hpp
@@ -27,9 +27,6 @@ public:
List<T>& operator+=(const List<T> other);
- std::istream& read(std::istream& istr);
- std::ostream& write(std::ostream& ostr) const;
-
unsigned get_length() const;
unsigned get_count() const;
@@ -42,6 +39,11 @@ public:
List& operator=(List&& other);
};
+template <typename T>
+std::istream& operator>>(std::istream& istr, List<T>& obj);
+template <typename T>
+std::ostream& operator<<(std::ostream& ostr, const List<T>& obj);
+
/* Private */
template <class T>
@@ -142,31 +144,6 @@ List<T>& List<T>::operator+=(const List<T> other) {
}
template <class T>
-std::istream& List<T>::read(std::istream& istr) {
- istr.read((char*)&length, sizeof(length));
- istr.read((char*)&count, sizeof(count));
-
- delete[] elements;
- elements = new T[length];
-
- for (int i = 0; i < count; i++)
- elements[i].read(istr); // disgusting
-
- return istr;
-}
-
-template <class T>
-std::ostream& List<T>::write(std::ostream& ostr) const {
- ostr.write((const char*)&length, sizeof(length));
- ostr.write((const char*)&count, sizeof(count));
-
- for (int i = 0; i < count; i++)
- elements[i].write(ostr); // disgusting
-
- return ostr;
-}
-
-template <class T>
unsigned List<T>::get_length() const {
return length;
}
@@ -222,4 +199,31 @@ List<T>& List<T>::operator=(List&& other) {
return *this;
}
+/* Other */
+
+template <typename T>
+std::istream& operator>>(std::istream& istr, List<T>& obj) {
+ istr.read((char*)&length, sizeof(length));
+ istr.read((char*)&count, sizeof(count));
+
+ delete[] elements;
+ elements = new T[length];
+
+ for (int i = 0; i < count; i++)
+ elements[i].read(istr); // disgusting
+
+ return istr;
+}
+
+template <typename T>
+std::ostream& operator<<(std::ostream& ostr, const List<T>& obj) {
+ ostr.write((const char*)&length, sizeof(length));
+ ostr.write((const char*)&count, sizeof(count));
+
+ for (int i = 0; i < count; i++)
+ elements[i].write(ostr); // disgusting
+
+ return ostr;
+}
+
#endif