Right now I'm trying to learn the c++ STL & every time I use the set or multiset data structure, my gcc compiler, returns an error message that I can't understand because it's so long (>40,000 characters).
Here is my program:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
int h, t;
cin >> n >> m;
multiset<int> si;
for (int i = 0; i < n; i++)
{
cin >> h;
si.insert(h);
}
sort(si.begin(), si.end());
vector<int>vi;
for (int i = 0; i < m; i++)
{
cin >> t;
vi.push_back(t);
}
sort(vi.begin(), vi.end());
int count = 0;
for (int i = 0; i < n; i++)
{
auto it = upper_bound(si.begin(), si.end(), vi[i]);
for (auto elem : si)
{
if (it != si.end() and (vi[i] == *it || vi[i] == elem))
{
count++;
}
}
}
cout << count;
}
This is the error message that I had to cut down because it was too long to fit in the body of my question:
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/valarray:1173:1: note:
candidate template ignored: could not match 'valarray' against
'_Rb_tree_const_iterator'
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/valarray:1155:5: note:
expanded from macro '_DEFINE_BINARY_OPERATOR'
operator _Op(const valarray<_Tp>& __v, const _Tp& __t...
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/valarray:1173:1: note:
candidate template ignored: could not match 'valarray' against
'_Rb_tree_const_iterator'
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/valarray:1165:5: note:
expanded from macro '_DEFINE_BINARY_OPERATOR'
operator _Op(const _Tp& __t, const valarray<_Tp>& __v...
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/complex:451:5: note:
candidate function template not viable: requires single argument
'__x', but 2 arguments were provided
operator-(const complex<_Tp>& __x)
^
2 errors generated.
What is producing this error?
And do you any advice on how to comprehend such long error messages?