no matching function call error using std::find

no matching member function for call to 'find' map
c++ no matching function for call to constructor
no matching function for call to 'find c++
no matching function for call to 'begin
no matching member function for call to find unordered_map
no match for call to c++
error: no matching function for call to equal
no matching member function for call to count

I have the following function (for testing):

static bool foo(void)
{
  std::string name = "name";
  std::vector<std::string> test;
  std::vector<std::string>::iterator vStart = test.begin();
  std::vector<std::string>::iterator vEnd = test.end();
  return (std::find(vStart, vEnd, name) == vEnd);
}

And I get a compilation error:

/data/src/fiware-orion/src/lib/common/string.cpp: In function 'bool foo()':
/data/src/fiware-orion/src/lib/common/string.cpp:167:39: error: no matching function for call to 'find(std::vector<std::basic_string<char> >::iterator&, std::vector<std::basic_string<char> >::iterator&, std::string&)'
   return (std::find(vStart, vEnd, name) == vEnd);
                                       ^
/data/src/fiware-orion/src/lib/common/string.cpp:167:39: note: candidate is:
In file included from /usr/include/c++/4.9/bits/locale_facets.h:48:0,
                 from /usr/include/c++/4.9/bits/basic_ios.h:37,
                 from /usr/include/c++/4.9/ios:44,
                 from /usr/include/c++/4.9/istream:38,
                 from /usr/include/c++/4.9/sstream:38,
                 from /data/src/fiware-orion/src/lib/common/string.cpp:31:
/usr/include/c++/4.9/bits/streambuf_iterator.h:369:5: note: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)
     find(istreambuf_iterator<_CharT> __first,
     ^
/usr/include/c++/4.9/bits/streambuf_iterator.h:369:5: note:   template argument deduction/substitution failed:
/data/src/fiware-orion/src/lib/common/string.cpp:167:39: note:   '__gnu_cxx::__normal_iterator<std::basic_string<char>*, std::vector<std::basic_string<char> > >' is not derived from 'std::istreambuf_iterator<_CharT>'
   return (std::find(vStart, vEnd, name) == vEnd);

Maybe the message which points to the problem is this:

template argument deduction/substitution failed:

but as far as I undersand the concrete classes used in the find() function argument (std::vector<std::string>::iterator, std::vector<std::string>::iterator and std::string) are clear.

What's specially surprises me is that this same code fragment for foo() function is working verbatim in other parts of my code (i.e. other .cpp files) so maybe it is related somehow with the #include chain in a way I'm not able to deduce or trace...

Any help is welcome!

There is no find from #include <algorithm> in the error message, only the one from streambuf_iterator.h. Add #include <algorithm>.

Compiler Error: No matching function for call to find, You forgot to include the <algorithm> header where std::find lives. You should also include <string> for access to std::string . You most likely  It just occurred to me that I not sure you showed the header file because I see no declarations of the data members which means that is the .cpp file, the implementation. If so, you actually DO need the "Platypus::" part in front of every method but you do not want the include guard or the "class Platypus" and ending "};" in there.

You are returning an iterator, but your function declaration is 'void'

std::find 'error no matching function', The error I get is error: no matching function for call to 'find(std::vector<A>::iterator​, std::vector<A>::iterator, A&). Am I missing something ? @Nuclear The point is that an std::find() can be found, but it's an overload with a different signature from a different header, which is not the one the OP was looking for. C++ is perfectly correct to complain in this case that the passed arguments do not enable resolution to any declared overload.

I think you forgot to include <algorithm>

Please add this #include <algorithm>

error: no matching function for call to 'find()', Problem. Today, I got a rather weird C++ error. That is. My code is very simply doing a search using the std::find() function as follow: std::find in C++. Find the element in the given range of numbers. Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last.

[Solved] Error "no matching function for call to" when trying to display , I see a couple of errors. The first is the prototype to the display method is : Hide Copy Code. void Platypus::display(ostream & out) const And the follow-up notes by gcc say that only std::find (std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&) was a candidate function to call. This means that <algorithm> header wasn't included at all. And indeed, at least PlatformState.cpp doesn't have it up to now.

no matching function for call to 'find(std::array<const char*, 6ul , cpp: In member function 'virtual Register DebuggerCore::PlatformState::value(​const QString&) const': unix/linux/PlatformState.cpp:719:80: error:  is it head or header if its header then there is part of the problem also the arguements arent defined in the header

no matching function vformat · Issue #1318 · fmtlib/fmt · GitHub, error: no matching function for call to 'vformat(std::string&, fmt::v6:: I've checked the release notes for the library but couldn't see any mentions of a change to neither vformat or make_format_args . Sign in to comment. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. error: no matching function

Comments
  • Thank you so much! The error text wasn't very clear... :)
  • You are right. It seems the compilation error about "not matching function" maskes the one about wrong return in the function. However, I have updated the question post to fix that.