mercredi 4 novembre 2020

Overload operator for different template parameters

#include <cstddef>

template <typename T, std::size_t MaxElements>
struct circular_buffer{};

template <typename circular_buffer>
bool operator==(const circular_buffer &a, const circular_buffer &b) {
    return true;
}

int main() {
    circular_buffer<int, 2> a;
    circular_buffer<int, 3> b;
    a == b;
    return 0;
}

This code is work only for 2==3. But my 2 != my 3. Help me to repair operator.

Aucun commentaire:

Enregistrer un commentaire