在所有类型的迭代器中,为什么没有支持stack,queue和priority_queueSTL 容器的模式?
#include <iostream>
#include <stack>
#include <algorithm>
int main(){
std::stack<int> values;
std::stack<int> valuesCopy;
values.push(98);
values.push(11);
values.push(14);
values.push(17);
values.push(20);
std::for_each( /* How can i manage this in a alternative way */,
[&](int value) mutable throw() -> void{ /* Process */ ;} );
std::copy(/* Same for this */,std::back_inserter(valuesCopy));
return 0;
}
Run Code Online (Sandbox Code Playgroud)