iter_swap(s...ve_iterator)(3)
π iter_swap(s...ve_iterator)(3) β C++ Standard Libary π
okay so bestie, welcome to the iter_swap(std::move_iterator) page from the C++ Standard Libary β yes, that's the manual name up top, typo and all, I'm not touching it π. This is iterator friendship content, and honestly? It ate.
π NAME π
iter_swap(std::move_iterator) - iter_swap(std::move_iterator)
That's the whole name, bestie. It's the std::move_iterator flavor of iter_swap, and it said what it said. π
π Synopsis π
template< std::indirectly_swappable<Iter> Iter2 >
friend constexpr void
iter_swap( const move_iterator& x, const
(since C++20)
std::move_iterator<Iter2>& y )
noexcept(/*see below*/);
Swaps the objects pointed to by two underlying iterators. The function body is equivalent to ranges::iter_swap(x.base(), y.base());.
This function template is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::move_iterator<Iter> is an associated class of the arguments.
π Parameters π
x,yβ move iterators to the elements to swap
β¨ Return value β¨
(none). Yes, nothing. It's a side-effect main character. π«Ά
π₯ Complexity π₯
Constant. That's the whole vibe.
π Exceptions π
noexcept specification:
noexcept(noexcept(ranges::iter_swap(x.base(), y.base())))
πΈ Example πΈ
// Run this code β literally go run it:
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
int main()
{
std::vector<std::string> p{"AA", "EE"},
q{"β±―β±―", "ΖΖ"};
std::move_iterator<std::vector<std::string>::iterator>
x = std::make_move_iterator(p.begin()),
y = std::make_move_iterator(q.begin());
std::cout << *x << ' ' << *y << '\n';
iter_swap(x, y); // ADL
std::cout << *x << ' ' << *y << '\n';
}
π Output π
AA β±―β±―
β±―β±― AA
π¦ See also π¦
swapβ swaps the values of two objects (function template)swap_rangesβ swaps two ranges of elements (function template)iter_swapβ swaps the elements pointed to by two iterators (function template)iter_swapβ swaps the values referenced by two dereferenceable objects (C++20) (customization point object)iter_swapβ swaps the objects pointed to by two adjusted underlying iterators (C++20) (function template)
π Category π
* conditionally noexcept
mwah π this page comes from http://cppreference.com, dated 2024.06.10, and its footer tag is iter_swap(s...ve_iterator)(3) β periodt. π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms