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