no match for 'operator' C/C++ Origin: Application & API Last updated 15 Oct 2026

C++: error: no match for 'operator<<' (operand types are 'std::ostream' and 'X')

You used an operator on a type that does not define it — most often printing your own class with << or comparing two objects.

Exact message you may see no match for 'operator<<'no match for 'operator=='no match for 'operator<'no match for call tocandidate: operator<<
Seen on: C/C++ GCC Clang

Meaning

C++ does not generate operator<<, == or < for your classes. The long list of "candidate" overloads that follows the message shows the closest built-in matches; none accept your type. Provide the operator as a free function (or member) and make sure it is visible where you use it.

Common causes

  • Class has no operator<< for std::ostream
  • Class has no operator== / operator< (needed by std::find, std::sort, std::map)
  • Operator declared in another namespace, so ADL cannot find it
  • const mismatch: operator takes a non-const reference
  • Missing #include <iostream> / <string>

⚡ Quick fix

  1. Define the operator for your type
  2. Put the operator in the same namespace as the class
  3. Take parameters by const reference

Detailed fix by platform

C++

  1. Declare std::ostream& operator<<(std::ostream& os, const Point& p); next to the class
  2. In C++20 you can write bool operator==(const Point&) const = default; or auto operator<=>(const Point&) const = default;

Code examples

Teach std::cout to print a class

cpp
#include <iostream>

struct Point { int x, y; };

std::ostream& operator<<(std::ostream& os, const Point& p) {
    return os << "(" << p.x << ", " << p.y << ")";
}

int main() {
    Point p{1, 2};
    std::cout << p << "\n";     // prints (1, 2)
}

How to diagnose

  1. Types — Operand types in the message?
  2. Namespace — Is the operator in the class's namespace?
  3. Const — Does the signature use const T&?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

call of overloaded is ambiguous — C++: error: call of overloaded 'f(int)' is ambiguous (C/C++)call of overloaded is…cannot declare variable to be of abstract type — C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions) (C/C++)cannot declare variab…discards qualifiers — C++: error: passing 'const X' as 'this' argument discards qualifiers [-fpermissive] (C/C++)discards qualifiersISO C++ forbids comparison between pointer and integer — C++: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] (C/C++)ISO C++ forbids compa…need typename before dependent name — C++: error: need 'typename' before 'T::iterator' because 'T' is a dependent scope (C/C++)need typename before …no matching function for call to — C++: error: no matching function for call to 'f(int, const char*)' (C/C++)no matching function …template argument deduction/substitution failed — C++: error: template argument deduction/substitution failed / couldn't deduce template parameter (C/C++)template argument ded…no match …

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.