C++ vector find error: no matching function for call to ‘find(std::vector::iterator, std::v

 
Using the find method to find elements in the vector, I found a strange problem.

When I independently verified the find function myself, I found that there was no problem. It’s weird going into this code.
/ home// XXX XXX. CPP: 163:63: error: no matching function for the call to ‘find (STD: : vector< int> ::iterator, std::vector< int> ::ite
rator, __gnu_cxx::__alloc_traits< std::allocator< int> > ::value_type&) ‘
it = find (tQubits. The begin (), tQubits. The end (), AllQubits [I]);
^
In the file included the from/usr/include/c + +/6/bits/locale_facets. H: 48:0,
the from The/usr/include/c + +/6/bits/basic_ios. H: 37,
the from/usr/include/c + +/6/ios: 44,
the from/usr/include/c + +/6/cost: 38,
the from/usr/include/c + +/6/fstream: 38,
the from/home/FDD/Quantum_simulator shor_factoring/core/QCore. H: 11,
the from /home/fdd/Quantum_simulator/shor_factoring/core/QCore.cpp:8:
/usr/include/c++/6/bits/streambuf_iterator.h:369:5: note: candidate: template< class _CharT2> typename __gnu_cxx::__enable_if< std::__is_char< _CharT2> ::__value, st
d::istreambuf_iterator< _CharT> > ::__type std::find(std::istreambuf_iterator< _CharT> , std::istreambuf_iterator< _CharT> , const _CharT2&)
the find (istreambuf_iterator & lt; _CharT> __first,
^ ~ ~ ~
/usr/include/c + +/6/bits/streambuf_iterator. H: 369-5: note: the template argument deduction/substitution failed:
/home// XXX XXX. CPP: 163-63: Note: ‘__gnu_cxx: : __normal_iterator & lt; int*, std::vector< int> > “Is not derived from ‘STD ::istre
ambuf_iterator< _CharT> ‘
it = find (tQubits. The begin (), tQubits. The end (), AllQubits [I]);
^
It took a long time, but I finally found a solution on a foreign website. The find function needs a header file containing the algorithm…
Add a line #include< algorithm> That’s it!
So I have to write a note, hoping to be helpful to future generations!

Read More: