std::move_iterator是准确表现为底层迭代器(必须至少是一个遗留输入迭代器(LegacyInputIterator))的迭代器适配器,除了解引用会将底层迭代器返回的值转换为右值。若此迭代器用作输入迭代器,则效果是值被移动,而非复制。 成员类型 成员类型定义 iterator_typeIter ...
explicit move_iterator( Iterator x ); (until C++17) constexpr explicit move_iterator( Iterator x ); (since C++17) (3) template< class U > move_iterator( const move_iterator<U>& other ); (until C++17) template< class U > constexpr move_iterator( const move_iterator<U>& ...
operator==(std::move_iterator<Iter>, std::move_sentinel) operator+(std::move_iterator) std::move_iterator<Iter>::move_iterator std::move_iterator<Iter>::operator= std::move_iterator<Iter>::base std::move_iterator<Iter>::operator*,-> std::move_iterator<Iter>::operator[] std::move_it...
对于类成员函数、lambda表达式或其他可调用对象就无能为力了,因此,C++11推出了std::function与std::...
std::make_move_iterator Defined in header<iterator> template<classIter> std::move_iterator<Iter>make_move_iterator(Iter i); (since C++11) (constexpr since C++17) make_move_iteratoris a convenience function template that constructs astd::move_iteratorfor the given iteratoriwith the type deduced...
iter_move(conststd::move_iterator&i)noexcept(/* see below */); (since C++20) Casts the result of dereferencing the underlying iterator to its associated rvalue reference type. The function body is equivalent to:returnstd::ranges::iter_move(i.base());. ...
std::move_iterator是准确表现为底层迭代器(必须至少是一个遗留输入迭代器(LegacyInputIterator)或实现input_iterator(C++20 起))的迭代器适配器,除了解引用会将底层迭代器返回的值转换为右值。若此迭代器用作输入迭代器,则效果是值被移动,而非复制。
使用move迭代器的唯一区别是,对迭代器的解引用会产生右值引用。如果只有复制赋值操作符可用,而没有移动赋值操作符,则这将用作“回退”。下面的代码演示了这一点:
make_move_iterator是对给定迭代器i构造类型从参数类型推出的std::move_iterator的便利函数模板。 参数 i-转换成移动迭代器的输入迭代器 返回值 可用于从通过i访问的元素移动的std::move_iterator。 可能的实现 template<classIter>constexpr// C++17 起std::move_iterator<Iter>make_move_iterator(Iter i){return...
使用std::array比普通的有什么优势?它具有友好的值语义,因此它可以通过值传递给函数或从函数返回。它...