C/C++字符串处理(5):std::deque与std::TextPool

本文深入探讨C++标准库中的deque容器,分析其基于分段连续数据结构的特点,比较deque与vector、list在时间与空间性能上的优劣,揭示deque作为高性能容器的优势。

C/C++字符串处理(5):std::deque与std::TextPool



许式伟
2008-4-4


引子

std::TextPool 基于 std::deque 实现。所以尽管本文讨论 std::deque,但是所有的结论对 std::TextPool 同样有效。

实现概要

顾名思义,这是一个“双向队列(double-ended queue)”。这意味着从队列开始和结束处插入(删除)数据的性能很好。为了达到这个目的,std::deque 基于一种分段连续的、介于数组和链表之间的数据结构,示意如下:

template <class _E>
class deque
{
enum { BlockSize = 512 };

typedef _E Block[BlockSize];

std::vector<Block*> m_storage;
iterator m_first, m_last;
};

其中,iterator是deque::iterator类。其具体实现我们这里不展开讨论,只是提示一点:这里m_first, m_last就是容器的begin(), end()。之所以需要它们,是因为m_storage的第一个Block和最后一个Block的数据可能没有填满,需要有指针去指出边界。设想一下如果 我们只是要实现一个单向的队列,那么可以去掉这里的m_first成员(因为第一个Block如果它不同时是最后一个Block,则不会不满)。

为什么需要采用这种分段连续的数据结构呢?答案是:性能。deque 平常很少为C++程序员所使用,但从容器的各方面的性能指标来看,实在不应该如此。可以说,deque 是 STL 中基于值的容器(它们包括:list/slist, vector, deque, basic_string等)中综合性能最优的类。

下面我们仔细分析一下。

时间性能分析

push_back/push_front

这两个操作对 deque 来说并无区别。而 vector 则不支持 push_front(因为性能很差而不提供)。我们对比各容器 push_back 性能。如下:

vector

vector::push_back 的性能具体要看 vector 的实现,主要关乎vector的内存增长模型。目前所见典型的做法是N*2模型,也就是说在申请的内存填满后,申请N*2字节的内存,这里N为当前 vector占用的空间。在此情况下,元素搬移的时间为 (1/N * N) = 1 为常数(其中1/N为平均搬移的次数,N为每次搬移的数据量),故此 push_back 的复杂度为 O(1)。但这种做法时间性能是有了,空间存在巨大的浪费。但是如果增长模型为N+Delta模型(这里Delta为一个常增长系数),那么元素搬移的时 间为 (1/Delta * N) = O(N)。空间是节约了,但时间性能极差。Erlang语言引入了一个很有意思的增长模型,是基于 Fibonacci 序列,空间浪费要好于N*2模型,兼顾了空间性能和时间性能。

list

list::push_back 的性能为O(1)。主要的时间开销为new Node时间。如果我们使用GC Allocator,list::push_back的速度非常快。

deque

deque::push_back 的性能接近O(1)。之所以不是O(1),是因为 m_storage 满了之后,会导致和 vector 一样的内存搬移问题。假设 vector<Block*> 采用了 2*N 增长模型,那么 deque::push_back 性能显然是 O(1)。如果采用 N+Delta 模型,那么元素搬移时间为 (1/(BlockSize*Delta) * N/BlockSize) = O(N)。虽然也是 O(N),但是一个是 N/Delta,一个是 N/(Delta*BlockSize*BlockSize),还是差别很大。由于 m_storage.size() 通常很小,所以实际情况下哪怕在海量数据情形下 deque::push_back 仍然表现良好。

operator[]

operator[] 是指通过下标取数据。显然 list 的复杂度为O(N),非常慢。而 vector、deque 均为 O(1)。让我们想象下 deque::operator[] 的实现:

_E deque::operator[](int i)
{
return m_storage[i/BlockSize][i%BlockSize];
}

可以看出,deque 只比 vector 多了一次内存访问。

空间性能分析

push_back

vector

很不幸,如果 vector 采用 N*2 的内存增长模型(通常如此),那么在最差的情况下,空间复杂度就是 2*N ,最好的情况下为 N(所有的内存都用上了)。平均来讲,空间复杂度为 1.5*N 。也就是说,通常差不多有一半的内存是被浪费的。

list

list 的空间浪费与 vector 相比不遑多让。它的空间复杂度为 (1 + sizeof(pointer)*2/sizeof(_E))*N。如果我们让 list 存储的元素为 pointer(即 _E = pointer),那么空间复杂度为 3*N,比 vector 还浪费。

deque

deque 的最差情况下的空间复杂度为 N + sizeof(pointer)*2*N/(BlockSize*sizeof(_E))(这里假设vector<Block*>也采用 2*N 增长模型,平均复杂度则将式中2改为1.5即可)。如果我们保存的元素为 pointer(即 _E = pointer),并且BlockSize取512,那么空间复杂度为 N + N/256。也就是说最差情况下只浪费了 N/256 的内存。

deque的其他特性

元素地址不变

由于 deque 并不进行数据搬移,带来一个有意思的特性,就是 deque 的元素地址在只有 push_back/push_front,没有 insert/erase 时,可保持元素地址不变。

需要注意的是,vector 并不具备这样的特性。如下的代码是不合法的:

std::vector<int> vec;
...
int& elem = vec[i];
vec.push_back(100);
elem = 99; // error: can't access elem since vec was changed!

由于取得 elem 之后存在 push_back 操作,所获得的元素地址(&elem)可能会由于内存搬移而失效。但是如果我们将容器换为 std::deque<int>,则这个代码不会有任何问题。

std::deque<int> dq;
...
int& elem = dq[i];
dq.push_back(100);
elem = 99; // ok!

另外需要注意的是,元素地址不变,并不代表 iterator 不变,如下的代码 deque 并不支持:

std::deque<int> dq;
...
std::deque<int>::iterator it = dq.begin() + i;
dq.push_back(100);
*
it = 99; // error: can't access iterator since deque was changed!

结论

通过 vector, list, deque 的时间、空间性能对比,我们可以看出,应该提倡尽可能使用 deque 这个容器。特别是,如果要承受海量数据,deque 是最合适的人选了。

相关参考

<!-- google_ad_section_start(weight=ignore) -->
else { if(q2.size() < n2) { q2.insert(q2.begin(),p); } else { q2.pop_back(); 测试结果 自测运行结果 自测输入 3 3 10 1 2 3 4 3 2 2 1 3 4 运行结果 step1/main.cpp: In function ‘void rmove(std::vector<int>&, int): step1/main.cpp:11:37: error: expected primary-expression before ‘int’ int it = find(v.begin(),v.end(),int e); ^~~ step1/main.cpp:12:12: error: no match for ‘operator!=’ (operand types are ‘int’ and ‘std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’) if (it != v.end()) v.erase(it); ~~~^~~~~~~~~~ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:951:5: note: candidate: template<class _BiIter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&) operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:951:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1029:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&) operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1029:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1109:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&) operator!=(const sub_match<_Bi_iter>& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1109:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1186:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&) operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1186:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1260:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*) operator!=(const sub_match<_Bi_iter>& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1260:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1337:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&) operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1337:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1417:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&) operator!=(const sub_match<_Bi_iter>& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1417:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/regex:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:110, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/regex.h:1944:5: note: candidate: template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const std::__cxx11::match_results<_BiIter, _Alloc>&, const std::__cxx11::match_results<_BiIter, _Alloc>&) operator!=(const match_results<_Bi_iter, _Alloc>& __m1, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/regex.h:1944:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::match_results<_BiIter, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/iosfwd:40:0, from /usr/local/include/c++/7.3.0/ios:38, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/postypes.h:221:5: note: candidate: template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&) operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/postypes.h:221:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::fpos<_StateT>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/stl_algobase.h:64:0, from /usr/local/include/c++/7.3.0/bits/char_traits.h:39, from /usr/local/include/c++/7.3.0/ios:40, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_pair.h:456:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_pair.h:456:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::pair<_T1, _T2>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/stl_algobase.h:67:0, from /usr/local/include/c++/7.3.0/bits/char_traits.h:39, from /usr/local/include/c++/7.3.0/ios:40, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_iterator.h:311:5: note: candidate: template<class _Iterator> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator!=(const reverse_iterator<_Iterator>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_iterator.h:311:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/stl_algobase.h:67:0, from /usr/local/include/c++/7.3.0/bits/char_traits.h:39, from /usr/local/include/c++/7.3.0/ios:40, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_iterator.h:349:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator!=(const reverse_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_iterator.h:349:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/stl_algobase.h:67:0, from /usr/local/include/c++/7.3.0/bits/char_traits.h:39, from /usr/local/include/c++/7.3.0/ios:40, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_iterator.h:1130:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator!=(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_iterator.h:1130:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/stl_algobase.h:67:0, from /usr/local/include/c++/7.3.0/bits/char_traits.h:39, from /usr/local/include/c++/7.3.0/ios:40, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_iterator.h:1136:5: note: candidate: template<class _Iterator> bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&) operator!=(const move_iterator<_Iterator>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_iterator.h:1136:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/string:41:0, from /usr/local/include/c++/7.3.0/bits/locale_classes.h:40, from /usr/local/include/c++/7.3.0/bits/ios_base.h:41, from /usr/local/include/c++/7.3.0/ios:42, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/allocator.h:158:5: note: candidate: template<class _T1, class _T2> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_T2>&) operator!=(const allocator<_T1>&, const allocator<_T2>&) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/allocator.h:158:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::allocator<_CharT>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/string:41:0, from /usr/local/include/c++/7.3.0/bits/locale_classes.h:40, from /usr/local/include/c++/7.3.0/bits/ios_base.h:41, from /usr/local/include/c++/7.3.0/ios:42, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/allocator.h:164:5: note: candidate: template<class _Tp> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_CharT>&) operator!=(const allocator<_Tp>&, const allocator<_Tp>&) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/allocator.h:164:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::allocator<_CharT>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/string:52:0, from /usr/local/include/c++/7.3.0/bits/locale_classes.h:40, from /usr/local/include/c++/7.3.0/bits/ios_base.h:41, from /usr/local/include/c++/7.3.0/ios:42, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/basic_string.h:6044:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/basic_string.h:6044:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/string:52:0, from /usr/local/include/c++/7.3.0/bits/locale_classes.h:40, from /usr/local/include/c++/7.3.0/bits/ios_base.h:41, from /usr/local/include/c++/7.3.0/ios:42, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/basic_string.h:6057:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator!=(const _CharT* __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/basic_string.h:6057:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const _CharT*’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/string:52:0, from /usr/local/include/c++/7.3.0/bits/locale_classes.h:40, from /usr/local/include/c++/7.3.0/bits/ios_base.h:41, from /usr/local/include/c++/7.3.0/ios:42, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/basic_string.h:6069:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/basic_string.h:6069:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/ios_base.h:46:0, from /usr/local/include/c++/7.3.0/ios:42, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/system_error:319:3: note: candidate: bool std::operator!=(const std::error_code&, const std::error_code&) operator!=(const error_code& __lhs, const error_code& __rhs) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/system_error:319:3: note: no known conversion for argument 1 from ‘int’ to ‘const std::error_code&’ /usr/local/include/c++/7.3.0/system_error:323:3: note: candidate: bool std::operator!=(const std::error_code&, const std::error_condition&) operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/system_error:323:3: note: no known conversion for argument 1 from ‘int’ to ‘const std::error_code&’ /usr/local/include/c++/7.3.0/system_error:327:3: note: candidate: bool std::operator!=(const std::error_condition&, const std::error_code&) operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/system_error:327:3: note: no known conversion for argument 1 from ‘int’ to ‘const std::error_condition&’ /usr/local/include/c++/7.3.0/system_error:331:3: note: candidate: bool std::operator!=(const std::error_condition&, const std::error_condition&) operator!=(const error_condition& __lhs, ^~~~~~~~ /usr/local/include/c++/7.3.0/system_error:331:3: note: no known conversion for argument 1 from ‘int’ to ‘const std::error_condition&’ In file included from /usr/local/include/c++/7.3.0/bits/locale_facets.h:48:0, from /usr/local/include/c++/7.3.0/bits/basic_ios.h:37, from /usr/local/include/c++/7.3.0/ios:44, from /usr/local/include/c++/7.3.0/istream:38, from /usr/local/include/c++/7.3.0/sstream:38, from /usr/local/include/c++/7.3.0/complex:45, from /usr/local/include/c++/7.3.0/ccomplex:39, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/streambuf_iterator.h:210:5: note: candidate: template<class _CharT, class _Traits> bool std::operator!=(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&) operator!=(const istreambuf_iterator<_CharT, _Traits>& __a, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/streambuf_iterator.h:210:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::istreambuf_iterator<_CharT, _Traits>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/ccomplex:39:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/complex:476:5: note: candidate: template<class _Tp> constexpr bool std::operator!=(const std::complex<_Tp>&, const std::complex<_Tp>&) operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/complex:476:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::complex<_Tp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/ccomplex:39:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/complex:481:5: note: candidate: template<class _Tp> constexpr bool std::operator!=(const std::complex<_Tp>&, const _Tp&) operator!=(const complex<_Tp>& __x, const _Tp& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/complex:481:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::complex<_Tp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/ccomplex:39:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:52, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/complex:486:5: note: candidate: template<class _Tp> constexpr bool std::operator!=(const _Tp&, const std::complex<_Tp>&) operator!=(const _Tp& __x, const complex<_Tp>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/complex:486:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::complex<_Tp>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/deque:64:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:68, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_deque.h:280:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> bool std::operator!=(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&) operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_deque.h:280:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/deque:64:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:68, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_deque.h:287:5: note: candidate: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator!=(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&) operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_deque.h:287:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/deque:64:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:68, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_deque.h:2284:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&) operator!=(const deque<_Tp, _Alloc>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_deque.h:2284:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::deque<_Tp, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/tuple:39:0, from /usr/local/include/c++/7.3.0/functional:54, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:71, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/array:257:5: note: candidate: template<class _Tp, long unsigned int _Nm> bool std::operator!=(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&) operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) ^~~~~~~~ /usr/local/include/c++/7.3.0/array:257:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::array<_Tp, _Nm>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/functional:54:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:71, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/tuple:1423:5: note: candidate: template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const std::tuple<_Tps ...>&, const std::tuple<_Elements ...>&) operator!=(const tuple<_TElements...>& __t, ^~~~~~~~ /usr/local/include/c++/7.3.0/tuple:1423:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::tuple<_Tps ...>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/functional:58:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:71, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/std_function.h:782:5: note: candidate: template<class _Res, class ... _Args> bool std::operator!=(const std::function<_Res(_ArgTypes ...)>&, std::nullptr_t) operator!=(const function<_Res(_Args...)>& __f, nullptr_t) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/std_function.h:782:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::function<_Res(_ArgTypes ...)>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/functional:58:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:71, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/std_function.h:788:5: note: candidate: template<class _Res, class ... _Args> bool std::operator!=(std::nullptr_t, const std::function<_Res(_ArgTypes ...)>&) operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/std_function.h:788:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::function<_Res(_ArgTypes ...)>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/locale_conv.h:41:0, from /usr/local/include/c++/7.3.0/locale:43, from /usr/local/include/c++/7.3.0/iomanip:43, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:72, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/unique_ptr.h:700:5: note: candidate: template<class _Tp, class _Dp, class _Up, class _Ep> bool std::operator!=(const std::unique_ptr<_Tp, _Dp>&, const std::unique_ptr<_Up, _Ep>&) operator!=(const unique_ptr<_Tp, _Dp>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/unique_ptr.h:700:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::unique_ptr<_Tp, _Dp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/locale_conv.h:41:0, from /usr/local/include/c++/7.3.0/locale:43, from /usr/local/include/c++/7.3.0/iomanip:43, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:72, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/unique_ptr.h:706:5: note: candidate: template<class _Tp, class _Dp> bool std::operator!=(const std::unique_ptr<_Tp, _Dp>&, std::nullptr_t) operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/unique_ptr.h:706:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::unique_ptr<_Tp, _Dp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/locale_conv.h:41:0, from /usr/local/include/c++/7.3.0/locale:43, from /usr/local/include/c++/7.3.0/iomanip:43, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:72, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/unique_ptr.h:711:5: note: candidate: template<class _Tp, class _Dp> bool std::operator!=(std::nullptr_t, const std::unique_ptr<_Tp, _Dp>&) operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/unique_ptr.h:711:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::unique_ptr<_Tp, _Dp>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/iterator:66:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:77, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stream_iterator.h:137:5: note: candidate: template<class _Tp, class _CharT, class _Traits, class _Dist> bool std::operator!=(const std::istream_iterator<_Tp, _CharT, _Traits, _Dist>&, const std::istream_iterator<_Tp, _CharT, _Traits, _Dist>&) operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stream_iterator.h:137:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::istream_iterator<_Tp, _CharT, _Traits, _Dist>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/list:63:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:79, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_list.h:293:5: note: candidate: template<class _Val> bool std::operator!=(const std::_List_iterator<_Tp>&, const std::_List_const_iterator<_Tp>&) operator!=(const _List_iterator<_Val>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_list.h:293:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::_List_iterator<_Tp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/list:63:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:79, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_list.h:1925:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::__cxx11::list<_Tp, _Alloc>&, const std::__cxx11::list<_Tp, _Alloc>&) operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_list.h:1925:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__cxx11::list<_Tp, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/map:60:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:81, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_tree.h:412:5: note: candidate: template<class _Val> bool std::operator!=(const std::_Rb_tree_iterator<_Tp>&, const std::_Rb_tree_const_iterator<_Val>&) operator!=(const _Rb_tree_iterator<_Val>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_tree.h:412:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::_Rb_tree_iterator<_Tp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/map:60:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:81, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_tree.h:1553:5: note: candidate: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator!=(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&) operator!=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_tree.h:1553:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/map:61:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:81, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_map.h:1419:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator!=(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&) operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_map.h:1419:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::map<_Key, _Tp, _Compare, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/map:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:81, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_multimap.h:1085:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator!=(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&) operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_multimap.h:1085:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::multimap<_Key, _Tp, _Compare, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/shared_ptr.h:52:0, from /usr/local/include/c++/7.3.0/memory:81, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:82, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1425:5: note: candidate: template<class _Tp1, class _Tp2, __gnu_cxx::_Lock_policy _Lp> bool std::operator!=(const std::__shared_ptr<_Tp1, _Lp>&, const std::__shared_ptr<_Tp2, _Lp>&) operator!=(const __shared_ptr<_Tp1, _Lp>& __a, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1425:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__shared_ptr<_Tp1, _Lp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/shared_ptr.h:52:0, from /usr/local/include/c++/7.3.0/memory:81, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:82, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1431:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator!=(const std::__shared_ptr<_Tp, _Lp>&, std::nullptr_t) operator!=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1431:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::__shared_ptr<_Tp, _Lp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/bits/shared_ptr.h:52:0, from /usr/local/include/c++/7.3.0/memory:81, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:82, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1436:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator!=(std::nullptr_t, const std::__shared_ptr<_Tp, _Lp>&) operator!=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/shared_ptr_base.h:1436:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::__shared_ptr<_Tp, _Lp>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/memory:81:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:82, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/shared_ptr.h:383:5: note: candidate: template<class _Tp, class _Up> bool std::operator!=(const std::shared_ptr<_Tp>&, const std::shared_ptr<_Up>&) operator!=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/shared_ptr.h:383:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::shared_ptr<_Tp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/memory:81:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:82, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/shared_ptr.h:388:5: note: candidate: template<class _Tp> bool std::operator!=(const std::shared_ptr<_Tp>&, std::nullptr_t) operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/shared_ptr.h:388:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::shared_ptr<_Tp>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/memory:81:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:82, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/shared_ptr.h:393:5: note: candidate: template<class _Tp> bool std::operator!=(std::nullptr_t, const std::shared_ptr<_Tp>&) operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/shared_ptr.h:393:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note:std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}’ is not derived from ‘const std::shared_ptr<_Tp>’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/vector:64:0, from /usr/local/include/c++/7.3.0/queue:61, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:86, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_vector.h:1620:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_vector.h:1620:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::vector<_Tp, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/queue:64:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:86, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_queue.h:342:5: note: candidate: template<class _Tp, class _Seq> bool std::operator!=(const std::queue<_Tp, _Seq>&, const std::queue<_Tp, _Seq>&) operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_queue.h:342:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::queue<_Tp, _Seq>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/set:61:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:87, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_set.h:937:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator!=(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&) operator!=(const set<_Key, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_set.h:937:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::set<_Key, _Compare, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/set:62:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:87, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_multiset.h:920:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator!=(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&) operator!=(const multiset<_Key, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_multiset.h:920:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::multiset<_Key, _Compare, _Alloc>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/stack:61:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:89, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/stl_stack.h:317:5: note: candidate: template<class _Tp, class _Seq> bool std::operator!=(const std::stack<_Tp, _Seq>&, const std::stack<_Tp, _Seq>&) operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) ^~~~~~~~ /usr/local/include/c++/7.3.0/bits/stl_stack.h:317:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::stack<_Tp, _Seq>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/valarray:592:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:95, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/valarray_after.h:415:5: note: candidate: template<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::__not_equal_to, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__not_equal_to, typename _Dom1::value_type>::result_type> std::operator!=(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&) _DEFINE_EXPR_BINARY_OPERATOR(!=, __not_equal_to) ^ /usr/local/include/c++/7.3.0/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: step1/main.cpp:12:21: note: mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘int’ if (it != v.end()) v.erase(it); ^ In file included from /usr/local/include/c++/7.3.0/valarray:592:0, from /usr/local/include/c++/7.3.0/x86_64-linux-gnu/bits/stdc++.h:95, from step1/main.cpp:1: /usr/local/include/c++/7.3.0/bits/valarray_after.h:415:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__not_equal_to, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__not_equal_to, typename _Dom1::value_type>::result_type> std::operator!=(const std::_Expr<_Dom1, type
最新发布
12-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值