iter_move(s...ve_iterator)(3)
π iter_move(s...ve_iterator)(3) π
okay bestie, welcome to the C++ Standard Library page for iter_move(s...ve_iterator)(3) β yes, that title is a whole mood. This is the std::move_iterator flavor of iter_move, and it's giving βI cast dereference results to rvaluesβ energy. π
πΈ NAME πΈ
iter_move(std::move_iterator) - iter_move(std::move_iterator) β no cap, the NAME section is literally echoing itself, and honestly? iconic. π
β¨ SYNOPSIS β¨
friend constexpr std::iter_rvalue_reference_t<Iter>
iter_move( const std::move_iterator& i ) noexcept(/* see below
(since C++20)
*/);
Since C++20, bestie. This casts the result of dereferencing the underlying iterator to its associated rvalue reference type. π¦
The function body is equivalent to this exact line: return std::ranges::iter_move(i.base()); β that's the whole move, periodt.
Important ADL tea: 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. iykyk. π«Ά
π PARAMETERS π
iβ a source move iterator.
π RETURN VALUE π
An rvalue reference or a prvalue temporary. That's it, that's the return vibe. β¨
π§ COMPLEXITY π§
Constant. β
π₯ EXCEPTIONS π₯
noexcept specification: noexcept(noexcept(ranges::iter_move(i.base()))) β yes, it's conditionally noexcept, and the spec is right there in all its nested-noexcept glory. π
π EXAMPLE π
// Run this code
#include <iomanip>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
void print(auto const& rem, auto const& v)
{
std::cout << rem << '[' << size(v) << "] { ";
for (char comma[]{0, ' ', 0}; auto const& s : v)
std::cout << comma << std::quoted(s), comma[0] = ',';
std::cout << " }\n";
}
int main()
{
std::vector<std::string> p{"Andromeda", "Cassiopeia", "Phoenix"}, q;
print("p", p), print("q", q);
using MI = std::move_iterator<std::vector<std::string>::iterator>;
for (MI first{p.begin()}, last{p.end()}; first != last; ++first)
q.emplace_back(/* ADL */ iter_move(first));
print("p", p), print("q", q);
}
π POSSIBLE OUTPUT π
p[3] { "Andromeda", "Cassiopeia", "Phoenix" }
q[0] { }
p[3] { "", "", "" }
q[3] { "Andromeda", "Cassiopeia", "Phoenix" }
π SEE ALSO π
iter_move(C++20) β casts the result of dereferencing an object to its associated rvalue reference type (customization point object).iter_move(C++20) β casts the result of dereferencing the adjusted underlying iterator to its associated rvalue reference type (function).move(C++11) β obtains an rvalue reference (function template).move_if_noexcept(C++11) β obtains an rvalue reference if the move constructor does not throw (function template).forward(C++11) β forwards a function argument (function template).ranges::move(C++20) β moves a range of elements to a new location (niebloid).ranges::move_backward(C++20) β moves a range of elements to a new location in backwards order (niebloid).
π·οΈ CATEGORY π·οΈ
conditionally noexcept β yes bestie, that category label is doing exactly what it says on the tin. π
okay that's the whole page, bestie β sourced from cppreference.com, dated 2024.06.10, mwah ππ«Ά
π¦ 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