From 4c1f8f7c13f22fc701206ea56dae30d26aca9bda Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 May 2022 16:03:34 +0300 Subject: Autocommit at 07.05.2022 @ 16:03 --- src/Generic/List/List.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Generic') diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp index d2a759f..2569380 100644 --- a/src/Generic/List/List.hpp +++ b/src/Generic/List/List.hpp @@ -25,6 +25,8 @@ public: T& operator[](unsigned index); const T& operator[](unsigned index) const; + List& operator+=(const List other); + std::istream& read(std::istream& istr); std::ostream& write(std::ostream& ostr) const; @@ -132,6 +134,13 @@ const T& List::operator[](unsigned index) const { return elements[index]; } +template +List& List::operator+=(const List other) { + for (unsigned i = 0; i < other.length; i++) + add(other[i]); + return *this; +} + template std::istream& List::read(std::istream& istr) { istr.read((char*)&length, sizeof(length)); -- cgit v1.3.1-26-gb76a