diff --git a/01_week/tasks/addition/addition.cpp b/01_week/tasks/addition/addition.cpp index 92872802..05ffd7d1 100644 --- a/01_week/tasks/addition/addition.cpp +++ b/01_week/tasks/addition/addition.cpp @@ -3,5 +3,5 @@ int64_t Addition(int a, int b) { - throw std::runtime_error{"Not implemented"}; + return static_cast(a) + static_cast(b); } \ No newline at end of file diff --git a/01_week/tasks/check_flags/check_flags.cpp b/01_week/tasks/check_flags/check_flags.cpp index 75e7c652..340c1c97 100644 --- a/01_week/tasks/check_flags/check_flags.cpp +++ b/01_week/tasks/check_flags/check_flags.cpp @@ -1,5 +1,6 @@ #include #include +#include enum class CheckFlags : uint8_t { @@ -14,5 +15,40 @@ enum class CheckFlags : uint8_t { }; void PrintCheckFlags(CheckFlags flags) { - throw std::runtime_error{"Not implemented"}; + // Значение находится в допустимом диапазоне + uint8_t value = static_cast(flags); + if (value == 0) { + std::cout << "[]"; + return; + } + if (value > static_cast(CheckFlags::ALL)) { + return; + } + // Последнее значение + if (value == static_cast(CheckFlags::ALL)) { + std::cout << "[TIME,DATE,USER,CERT,KEYS,DEST]"; + return; + } + + std::cout << "["; + bool first = true; + + const std::pair flag_names[] = { + {CheckFlags::TIME, "TIME"}, + {CheckFlags::DATE, "DATE"}, + {CheckFlags::USER, "USER"}, + {CheckFlags::CERT, "CERT"}, + {CheckFlags::KEYS, "KEYS"}, + {CheckFlags::DEST, "DEST"} + }; + + for (const auto& [flag, name] : flag_names) { + if (value & static_cast(flag)) { + if (!first) std::cout << ","; + std::cout << name; + first = false; + } + } + + std::cout << "]"; } diff --git a/01_week/tasks/length_lit/length_lit.cpp b/01_week/tasks/length_lit/length_lit.cpp index e69de29b..c9e08123 100644 --- a/01_week/tasks/length_lit/length_lit.cpp +++ b/01_week/tasks/length_lit/length_lit.cpp @@ -0,0 +1,55 @@ +double FT_IN_M = 1.0 / 0.3048; +double FT_IN_INCHES = 12.0; +double INCH_IN_CM = 2.54; + +// Футы в другие величины +double operator""_ft_to_m(long double ft) { + return ft / FT_IN_M; +} + +double operator""_ft_to_cm(long double ft) { + return ft / FT_IN_M * 100.0; +} + +double operator""_ft_to_in(long double ft) { + return ft * FT_IN_INCHES; +} + +// Дюймы в другие величины +double operator""_in_to_ft(long double in) { + return in / FT_IN_INCHES; +} + +double operator""_in_to_cm(long double in) { + return in * INCH_IN_CM; +} + +double operator""_in_to_m(long double inches) { + return inches * INCH_IN_CM / 100; +} + +// См в другие величины +double operator""_cm_to_m(long double centimeters) { + return centimeters / 100; +} + +double operator""_cm_to_in(long double centimeters) { + return centimeters / INCH_IN_CM; +} + +double operator""_cm_to_ft(long double centimeters) { + return centimeters / (FT_IN_INCHES * INCH_IN_CM); +} + +// Метры в другие величины +double operator""_m_to_ft(long double meters) { + return meters * 100 / (INCH_IN_CM * FT_IN_INCHES); +} + +double operator""_m_to_in(long double meters) { + return meters * 100 / INCH_IN_CM; +} + +double operator""_m_to_cm(long double meters) { + return meters * 100; +} \ No newline at end of file diff --git a/01_week/tasks/print_bits/print_bits.cpp b/01_week/tasks/print_bits/print_bits.cpp index a48a43c1..8dbbc6fa 100644 --- a/01_week/tasks/print_bits/print_bits.cpp +++ b/01_week/tasks/print_bits/print_bits.cpp @@ -1,7 +1,27 @@ #include #include +#include void PrintBits(long long value, size_t bytes) { - throw std::runtime_error{"Not implemented"}; + using std::cout; + // Проверка корректности размера + if (bytes == 0 || bytes > 8) { + return; + } + std::cout << "0b"; + + // Проходим по всем битам, начиная со старшего + for (size_t pos = bytes * 8; pos > 0; --pos) { + // Получаем значение бита на текущей позиции + int bit = (value >> (pos - 1)) & 1; + std::cout << bit; + + // Добавляем апостроф между байтами (после каждых 4 бит, кроме последней группы) + if ((pos - 1) > 0 && (pos - 1) % 4 == 0) { + std::cout << "'"; + } + } + + std::cout << "\n"; } diff --git a/01_week/tasks/quadratic/quadratic.cpp b/01_week/tasks/quadratic/quadratic.cpp index abf7d632..6e3c300c 100644 --- a/01_week/tasks/quadratic/quadratic.cpp +++ b/01_week/tasks/quadratic/quadratic.cpp @@ -1,6 +1,56 @@ #include +#include +#include +#include +void PrintRoot(double x) { + // Для избавления от заведомо небольших значений + if (std::abs(x) < 1e-10) { + x = 0.0; + } + std::cout << std::setprecision(6) << x; +} void SolveQuadratic(int a, int b, int c) { - throw std::runtime_error{"Not implemented"}; + if(a == 0 && b == 0 && c == 0) { + std::cout << "infinite solutions"; + return; + } + + double a_ = static_cast(a); + double b_ = static_cast(b); + double c_ = static_cast(c); + + if(a_ == 0) { + if(b_ == 0) { + // Нет решений + std::cout << "no solutions"; + } else { + // Один корень линейного уравнения + PrintRoot(-c_ / b_); + } + return; + } + + double D = b_*b_ - 4*a_*c_; + if (D > 0) { + double sqrt_d = std::sqrt(D); + double x1 = (-b_ - sqrt_d) / (2.0 * a_); + double x2 = (-b_ + sqrt_d) / (2.0 * a_); + + // Гарантируем, что x1 < x2 + if (x1 > x2) { + std::swap(x1, x2); + } + PrintRoot(x1); + std::cout << " "; + PrintRoot(x2); + } + else if (D == 0) { + double x = -b_ / (2.0 * a_); + PrintRoot(x); + } + else { + std::cout << "no solutions"; + } } \ No newline at end of file diff --git a/01_week/tasks/rms/rms.cpp b/01_week/tasks/rms/rms.cpp index 6882f0a9..06782da0 100644 --- a/01_week/tasks/rms/rms.cpp +++ b/01_week/tasks/rms/rms.cpp @@ -1,7 +1,15 @@ -#include +#include #include +#include double CalculateRMS(double values[], size_t size) { - throw std::runtime_error{"Not implemented"}; + if(size == 0 || values == nullptr) { // Проверка на отсутствие элементов в массиве и на нулевой указатель + return 0.0; + } + double square_sum = 0.0; + for(size_t i = 0; i < size; ++i) { + square_sum += values[i] * values[i]; + } + return sqrt(square_sum/size); } \ No newline at end of file diff --git a/02_week/tasks/func_array/func_array.cpp b/02_week/tasks/func_array/func_array.cpp index b327e68d..aa461fe8 100644 --- a/02_week/tasks/func_array/func_array.cpp +++ b/02_week/tasks/func_array/func_array.cpp @@ -1,6 +1,16 @@ -#include -double ApplyOperations(double a, double b /* other arguments */) { - throw std::runtime_error{"Not implemented"}; +double ApplyOperations(double a, double b, double (*ptr[])(double, double), size_t size) { + double sum = 0.0; + + if(size == 0 || ptr == nullptr) { + return sum; + } + + for (size_t i = 0; i < size; ++i) { + if(ptr[i] == nullptr) continue; + sum += ptr[i](a, b); + } + + return sum; } \ No newline at end of file diff --git a/02_week/tasks/last_of_us/last_of_us.cpp b/02_week/tasks/last_of_us/last_of_us.cpp index c7bf1a25..c4290840 100644 --- a/02_week/tasks/last_of_us/last_of_us.cpp +++ b/02_week/tasks/last_of_us/last_of_us.cpp @@ -1,6 +1,11 @@ #include -/* return_type */ FindLastElement(/* ptr_type */ begin, /* ptr_type */ end, /* func_type */ predicate) { - throw std::runtime_error{"Not implemented"}; +const int* FindLastElement(const int* begin, const int* end, bool (*predicate)(const int)) { + if((begin > end) || (begin == nullptr) || (end == nullptr)) return end; + + for(const int* ptr = end - 1; ptr >= begin; --ptr) { + if (predicate(*ptr)) {return ptr;} + } + return end; } \ No newline at end of file diff --git a/02_week/tasks/little_big/little_big.cpp b/02_week/tasks/little_big/little_big.cpp index abe24379..799259df 100644 --- a/02_week/tasks/little_big/little_big.cpp +++ b/02_week/tasks/little_big/little_big.cpp @@ -1,10 +1,45 @@ #include +#include +#include +#include -void PrintMemory(int /* write arguments here */) { - throw std::runtime_error{"Not implemented"}; +void PrintMemory(int value, bool reverse = false) { + unsigned char* bytes = reinterpret_cast(&value); + + std::cout << "0x"; + + if (reverse) { + // Вывод в обратном порядке (big-endian) + for (int i = sizeof(int) - 1; i >= 0; --i) { + std::cout << std::hex << std::uppercase << std::setw(2) << std::setfill('0') << static_cast(bytes[i]); + } + } else { + // Вывод в естественном порядке (little-endian) + for (size_t i = 0; i < sizeof(int); ++i) { + std::cout << std::hex << std::uppercase << std::setw(2) << std::setfill('0') << static_cast(bytes[i]); + } + } + + std::cout << std::endl; } -void PrintMemory(double /* write arguments here */) { - throw std::runtime_error{"Not implemented"}; +void PrintMemory(double value, bool reverseBytes = false) { + unsigned char* bytes = reinterpret_cast(&value); + + std::cout << "0x"; + + if (reverseBytes) { + // Вывод в обратном порядке (big-endian) + for (int i = sizeof(double) - 1; i >= 0; --i) { + std::cout << std::hex << std::uppercase << std::setw(2) << std::setfill('0') << static_cast(bytes[i]); + } + } else { + // Вывод в естественном порядке (little-endian) + for (size_t i = 0; i < sizeof(double); ++i) { + std::cout << std::hex << std::uppercase << std::setw(2) << std::setfill('0') << static_cast(bytes[i]); + } + } + + std::cout << std::endl; } \ No newline at end of file diff --git a/02_week/tasks/longest/longest.cpp b/02_week/tasks/longest/longest.cpp index 04b3c354..cdb03438 100644 --- a/02_week/tasks/longest/longest.cpp +++ b/02_week/tasks/longest/longest.cpp @@ -1,6 +1,34 @@ #include -/* return_type */ FindLongestSubsequence(/* ptr_type */ begin, /* ptr_type */ end, /* type */ count) { - throw std::runtime_error{"Not implemented"}; +char* FindLongestSubsequence(const char* begin, const char* end, size_t& count) { + if (begin == nullptr || end == nullptr || begin >= end) { + count = 0; + return nullptr; + } + + const char* longest_ptr = begin; + const char* current_ptr = begin; + size_t max_count = 1; + size_t current_count = 1; + + for (const char* ptr = begin + 1; ptr < end; ++ptr) { + if (*ptr == *(ptr - 1)) { + current_count++; + } else { + if(current_count > max_count) { + max_count = current_count; + longest_ptr = current_ptr; + } + current_ptr = ptr; + current_count = 1; + } + } + + if(current_count > max_count) { + max_count = current_count; + longest_ptr = current_ptr; + } + count = max_count; + return const_cast(longest_ptr); } diff --git a/02_week/tasks/pretty_array/pretty_array.cpp b/02_week/tasks/pretty_array/pretty_array.cpp index 48eab341..30509eb0 100644 --- a/02_week/tasks/pretty_array/pretty_array.cpp +++ b/02_week/tasks/pretty_array/pretty_array.cpp @@ -1,6 +1,38 @@ #include +#include - -void PrintArray(/* write arguments here */) { - throw std::runtime_error{"Not implemented"}; +void PrintArray(const int* begin, const int* end, int constraint = 0) { + if (begin == end || begin == nullptr || end == nullptr) + { + std::cout << "[]\n"; + return; + } + + int count = 0; + std::cout << "["; + if(begin < end) { + for(const int* ptr = begin; ptr < end; ++ptr) { + if((count == constraint) && (constraint != 0)) { + count = 0; + std::cout << "...\n "; + } + std::cout << *ptr; + if(ptr != end - 1) { std::cout << ", "; } + ++count; + } + std::cout << "]\n"; + } else { + ++end; + for(const int* ptr = begin; ptr >= end; --ptr) { + if((count == constraint) && (constraint != 0)) { + count = 0; + std::cout << "...\n "; + } + std::cout << *ptr; + if(ptr != end) { std::cout << ", "; } + if(ptr == end) { break; } + ++count; + } + std::cout << "]\n"; + } } \ No newline at end of file diff --git a/02_week/tasks/swap_ptr/swap_ptr.cpp b/02_week/tasks/swap_ptr/swap_ptr.cpp index 93db625d..ab74aef4 100644 --- a/02_week/tasks/swap_ptr/swap_ptr.cpp +++ b/02_week/tasks/swap_ptr/swap_ptr.cpp @@ -1,6 +1,17 @@ #include -void SwapPtr(/* write arguments here */) { - throw std::runtime_error{"Not implemented"}; +template +void SwapPtr(T*& ptr1, T*& ptr2) { + // Проверяем, указывают ли ptr1 и ptr2 на указатели + if constexpr (std::is_pointer_v>) { + // T* - это указатель на указатель (например: int**) + // Меняем значения, на которые указываем + SwapPtr(*ptr1, *ptr2); // Рекурсивный вызов + } + + // Меняем сами указатели + T* temp = ptr1; + ptr1 = ptr2; + ptr2 = temp; } \ No newline at end of file diff --git a/03_week/tasks/data_stats/data_stats.cpp b/03_week/tasks/data_stats/data_stats.cpp index b941c211..49bbdd56 100644 --- a/03_week/tasks/data_stats/data_stats.cpp +++ b/03_week/tasks/data_stats/data_stats.cpp @@ -1,11 +1,31 @@ #include - +#include +#include struct DataStats { double avg = 0.0; double sd = 0.0; }; -/* return_type */ CalculateDataStats(/* args */) { - throw std::runtime_error{"Not implemented"}; +DataStats CalculateDataStats(std::vector numbers) { + DataStats stats; + + if(numbers.empty()) { + return stats; + } + + for(auto num : numbers) { + stats.avg += num; + stats.sd += static_cast(num) * num; + } + // Вычисляем среднее значение + stats.avg = static_cast(stats.avg) / numbers.size(); + + if (numbers.size() > 1) { + stats.sd = std::sqrt((stats.sd - numbers.size() * stats.avg * stats.avg) / numbers.size()); + } + else { + stats.sd = 0; + } + return stats; } diff --git a/03_week/tasks/easy_compare/easy_compare.cpp b/03_week/tasks/easy_compare/easy_compare.cpp index dd5cb7f6..8145b476 100644 --- a/03_week/tasks/easy_compare/easy_compare.cpp +++ b/03_week/tasks/easy_compare/easy_compare.cpp @@ -1,10 +1,17 @@ #include +#include +int markPriority(char mark) { + static const std::map priority = { + {'Z', 0}, {'D', 1}, {'C', 2}, {'B', 3}, {'A', 4} + }; + return priority.at(mark); +} struct Date { - unsigned year; - unsigned month; - unsigned day; + unsigned year = 0u; + unsigned month = 0u; + unsigned day = 0u; }; struct StudentInfo { @@ -13,4 +20,43 @@ struct StudentInfo { int score; unsigned course; Date birth_date; -}; \ No newline at end of file +}; + +bool operator==(const Date& lhs, const Date& rhs) { + return std::tie(lhs.year, lhs.month, lhs.day) == + std::tie(rhs.year, rhs.month, rhs.day); +} + +bool operator<(const Date& lhs, const Date& rhs) { + return std::tie(lhs.year, lhs.month, lhs.day) < + std::tie(rhs.year, rhs.month, rhs.day); +} + +bool operator<=(const Date& lhs, const Date& rhs) { + return lhs < rhs || lhs == rhs; +} + +bool operator>(const Date& lhs, const Date& rhs) { + return !(lhs <= rhs); +} + +bool operator>=(const Date& lhs, const Date& rhs) { + return !(lhs < rhs); +} + +bool operator==(const StudentInfo& lhs, const StudentInfo& rhs) { + return lhs.mark == rhs.mark && lhs.score == rhs.score; +} + +bool operator<(const StudentInfo& lhs, const StudentInfo& rhs) { + if (markPriority(lhs.mark) != markPriority(rhs.mark)) { + return markPriority(lhs.mark) < markPriority(rhs.mark); + } + if (lhs.score != rhs.score) { + return lhs.score < rhs.score; + } + if (lhs.course != rhs.course) { + return lhs.course > rhs.course; + } + return lhs.birth_date < rhs.birth_date; +} diff --git a/03_week/tasks/filter/filter.cpp b/03_week/tasks/filter/filter.cpp index 6648cb39..06fe0a15 100644 --- a/03_week/tasks/filter/filter.cpp +++ b/03_week/tasks/filter/filter.cpp @@ -1,6 +1,21 @@ #include +#include -/* return_type */ Filter(/* args */) { - throw std::runtime_error{"Not implemented"}; +void Filter(std::vector& vec, bool (*predicate)(int)) { + size_t write_index = 0; + + if (vec.empty() || predicate == nullptr) { + return; + } + + for (size_t i = 0; i < vec.size(); ++i) { + if (predicate(vec[i])) { + if (i != write_index) { + vec[write_index] = vec[i]; + } + ++write_index; + } + } + vec.resize(write_index); } \ No newline at end of file diff --git a/03_week/tasks/find_all/find_all.cpp b/03_week/tasks/find_all/find_all.cpp index 74f393b2..d2951d54 100644 --- a/03_week/tasks/find_all/find_all.cpp +++ b/03_week/tasks/find_all/find_all.cpp @@ -1,6 +1,18 @@ #include +#include - -/* return_type */ FindAll(/* args */) { - throw std::runtime_error{"Not implemented"}; +std::vector FindAll(const std::vector& container, bool (*predicate)(int)) { + if(container.empty() || predicate == nullptr) { + return {}; + } + + std::vector result; + + for (size_t i = 0; i < container.size(); ++i) { + if (predicate(container[i])) { + result.push_back(i); + } + } + result.shrink_to_fit(); + return result; } \ No newline at end of file diff --git a/03_week/tasks/minmax/minmax.cpp b/03_week/tasks/minmax/minmax.cpp index c2869799..68c8e928 100644 --- a/03_week/tasks/minmax/minmax.cpp +++ b/03_week/tasks/minmax/minmax.cpp @@ -1,6 +1,45 @@ #include +#include +using IntVecIterator = std::vector::const_iterator; -/* return_type */ MinMax(/* args */) { - throw std::runtime_error{"Not implemented"}; +std::pair MinMax(const std::vector& numbers) { + if (numbers.empty()) { + return {numbers.end(), numbers.end()}; + } + + IntVecIterator min_it = numbers.begin(); + IntVecIterator max_it = numbers.begin(); + + auto it = numbers.begin() + 1; + const auto last = numbers.end(); + + while (it + 1 < last) { + IntVecIterator a = it; + IntVecIterator b = it + 1; + + IntVecIterator local_min, local_max; + if (*a <= *b) { + local_min = a; + local_max = b; + } else { + local_min = b; + local_max = a; + } + + if (*local_min < *min_it) min_it = local_min; + if (*local_max >= *max_it) max_it = local_max; + + it += 2; + } + + if (it != last) { + if (*it < *min_it) { + min_it = it; + } else if (*it >= *max_it) { + max_it = it; + } + } + + return {min_it, max_it}; } diff --git a/03_week/tasks/os_overload/os_overload.cpp b/03_week/tasks/os_overload/os_overload.cpp index e473418d..ba566298 100644 --- a/03_week/tasks/os_overload/os_overload.cpp +++ b/03_week/tasks/os_overload/os_overload.cpp @@ -1,21 +1,60 @@ #include #include #include +#include struct Coord2D { int x; int y; + Coord2D(int x_val = 0, int y_val = 0) : x(x_val), y(y_val) {} }; struct Circle { Coord2D coord; - unsigned radius; + unsigned radius = 1; + Circle() : coord(), radius(1) {} // Default + explicit Circle(Coord2D c, unsigned r = 1) : coord(c), radius(r) {} + Circle(unsigned r) : coord(), radius(r) {} }; using CircleRegion = std::pair; using CircleRegionList = std::vector; -/* return_type */ operator<<(/* args */) { - throw std::runtime_error{"Not implemented"}; +// Оператор вывода для Coord2D +std::ostream& operator<<(std::ostream& os, const Coord2D& coord) { + os << '(' << coord.x << ", " << coord.y << ')'; + return os; +} + +// Оператор вывода для Circle +std::ostream& operator<<(std::ostream& os, const Circle& circle) { + os << "circle["; + if (circle.radius > 0) { + os << circle.coord << ", r = " << circle.radius; + } + os << ']'; + return os; +} + +// Оператор вывода для CircleRegion +std::ostream& operator<<(std::ostream& os, const CircleRegion& region) { + os << (region.second ? '+' : '-') << region.first; + return os; +} + +std::ostream& operator<<(std::ostream& os, const CircleRegionList& circle_vector) { + os << '{'; + if (!circle_vector.empty()) { + os << '\n'; + for (auto it = circle_vector.begin(); it != circle_vector.end(); ++it) { + os << '\t' << *it; + if (std::next(it) != circle_vector.end()) { + os << ','; + } + os << '\n'; + } + } + os << '}'; + return os; } diff --git a/03_week/tasks/range/range.cpp b/03_week/tasks/range/range.cpp index d2085495..a9f67dc8 100644 --- a/03_week/tasks/range/range.cpp +++ b/03_week/tasks/range/range.cpp @@ -2,6 +2,29 @@ #include -std::vector Range(int from, int to, int step) { - throw std::runtime_error{"Not implemented"}; +std::vector Range(int from, int to, int step = 1) { + int size = 0; + if(from == to || (from > to && step > 0) || (from < to && step < 0) || step == 0) { + return {}; + } + if ((step > 0 && from < to) || (step < 0 && from > to)) { + size = (std::abs(to - from) + std::abs(step) - 1) / std::abs(step); + } + std::vector sequence; + sequence.reserve(size); + + int current = from; + if (step > 0) { + while (current < to) { + sequence.push_back(current); + current += step; + } + } else { + while (current > to) { + sequence.push_back(current); + current += step; + } + } + + return sequence; } diff --git a/03_week/tasks/unique/unique.cpp b/03_week/tasks/unique/unique.cpp index 9d2545bb..9161363c 100644 --- a/03_week/tasks/unique/unique.cpp +++ b/03_week/tasks/unique/unique.cpp @@ -1,6 +1,17 @@ #include #include -/* return_type */ Unique(/* args */) { - throw std::runtime_error{"Not implemented"}; -} +std::vector Unique(std::vector sorted_nums) { + std::vector unique_nums; + if(sorted_nums.empty()) {return unique_nums;} + int previous = *(sorted_nums.begin()); + unique_nums.push_back(previous); + for(auto num : sorted_nums) { + if(previous != num) { + previous = num; + unique_nums.push_back(previous); + } + } + unique_nums.shrink_to_fit(); + return unique_nums; +} \ No newline at end of file diff --git a/04_week/tasks/stack/stack.cpp b/04_week/tasks/stack/stack.cpp index 222e4ffc..7e1ee2fe 100644 --- a/04_week/tasks/stack/stack.cpp +++ b/04_week/tasks/stack/stack.cpp @@ -2,5 +2,63 @@ class Stack { + std::vector storage; +public: + Stack() = default; + ~Stack() = default; + void Push(int); + bool Pop(); + int& Top(); + const int& Top() const; + bool Empty() const; + size_t Size() const; + void Clear(); + void Swap(Stack&); + friend bool operator==(const Stack& lhs, const Stack& rhs); + friend bool operator!=(const Stack&, const Stack&); }; + +void Stack::Push(int a) { + storage.push_back(a); +} + +bool Stack::Pop() { + if(storage.empty()) { + return false; + } + storage.pop_back(); + return true; +} + +int& Stack::Top() { + return storage.back(); +} + +const int& Stack::Top() const { + return storage.back(); +} + +bool Stack::Empty() const { + return storage.empty(); +} + +size_t Stack::Size() const { + return storage.size(); +} + +void Stack::Clear() { + storage.clear(); +} + +void Stack::Swap(Stack& other) { + storage.swap(other.storage); +} + +bool operator==(const Stack& lhs, const Stack& rhs) { + return lhs.storage == rhs.storage; +} + +bool operator!=(const Stack& lhs, const Stack& rhs) { + return lhs.storage != rhs.storage; +}