std::front_insert_iterator<Container>::operator=
来自cppreference.com
< cpp | iterator | front insert iterator
(1) | ||
front_insert_iterator<Container>& operator=( typename Container::const_reference value ); |
(C++11 前) | |
front_insert_iterator<Container>& operator=( const typename Container::value_type& value ); |
(C++11 起) (C++20 前) |
|
constexpr front_insert_iterator<Container>& operator=( const typename Container::value_type& value ); |
(C++20 起) | |
(2) | ||
front_insert_iterator<Container>& operator=( typename Container::value_type&& value ); |
(C++11 起) (C++20 前) |
|
constexpr front_insert_iterator<Container>& operator=( typename Container::value_type&& value ); |
(C++20 起) | |
插入给定的 value
到迭代器。
1) 导致 container->push_front(value)
2) 导致 container->push_front(std::move(value))
参数
value | - | 要插入的值 |
返回值
*this
示例
运行此代码
#include <iostream> #include <iterator> #include <deque> int main() { std::deque<int> q; std::front_insert_iterator< std::deque<int> > it(q); for (int i=0; i<10; ++i) it = i; // 调用 q.push_front(i) for (auto& elem : q) std::cout << elem << ' '; }
输出:
9 8 7 6 5 4 3 2 1 0