0

I am trying to create a class with type parameter, and I want to assign the parameter only if it overrides the "==" operator.

something like this:

template <class T where T is override the operator "==" >
class Dictionary {
private:
    .
    .
    .

public:
    .
    .
    .
};

The idea is to make the compiler to not allow any class that is not overrides the specific operator, as a T type.

I could't find the answer here: How to check whether operator== exists?

Thanks for helpers!

Community
  • 1
  • 1
Coral Kashri
  • 3,436
  • 2
  • 10
  • 22
  • https://stackoverflow.com/questions/6534041/how-to-check-whether-operator-exists provides some useful typetraits. Couple it with a static assert to enforce the condition. – Kinan Al Sarmini May 19 '17 at 23:17
  • I don't think that it is the same issue.. I couldn't understand the issue there, or the answers. I don't want to check in run time if the class has override of the operator, I want that the compiler will know this, as it is work in c#. – Coral Kashri May 19 '17 at 23:36

0 Answers0