/
AirLexa
/
04
Обзор
Документация
Войти
/
AirLexa
/
04
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lesson_09/Task_1/Task_1.cpp
34 строки
891 B
AirLexa
загрузка урока 8
03 мар 2026, 18:21
Верифицирован
03 мар 2026, 18:21
eab1eca
Код
Авторство
О чём код?
#include <iostream> #include <iterator> #include <vector> #include <algorithm> template<typename T> void move_vectors(std::vector<T>& src, std::vector<T>& dst) { if (dst.empty()) dst = std::move(src); else { dst.reserve(dst.size() + src.size()); std::move(std::begin(src), std::end(src), std::back_inserter(dst)); src.clear(); } } int main() { std::vector <std::string> one = { "test_string1", "test_string2" }; std::cout << "one:\n"; std::for_each(one.begin(), one.end(), [](const std::string& s) { std::cout << s << ' '; }); std::cout << std::endl; std::vector <std::string> two; move_vectors(one, two); std::cout << "two:\n"; std::for_each(two.begin(), two.end(), [](const std::string& s) { std::cout << s << ' '; }); std::cout << std::endl; return 0; }