...

/

Define your Concepts: Equal and Ord

Define your Concepts: Equal and Ord

In this lesson, we'll define the concepts Equal and Ord for C++.

Eq versus Equal

The Type Class Eq (Haskell)

class Eq a where
  (==) :: a -> a -> Bool
  (/=) :: a -> a -> Bool




The Concept Equal (C++)

template <typename T>
concept bool Equal(){
  return requires(T a, T b){
    { a == b } -> bool;
    { a != b } -> bool;
  };
}

Let’s have a closer look at Haskell’s type class Eq. Eq requires from its instances, that

  • they have equal == and unequal /= operation that returns a Bool.
  • both take two arguments (a -> a
...
Access this course and 1400+ top-rated courses and projects.