vendredi 1 juillet 2016

How to overload << operator of non-type parameter template alias?

I wanna overload operator<< of a non-type parameter template alias.

#include <iostream>
#include <bitset>

template<int N>
using centroids = std::vector<typename std::bitset<N>>;

template<int N>
std::ostream & operator<<(std::ostream & o, centroids<N> const & c)
{
    return o;
}

int main()
{
    centroids<16> c;
    std::cout << c << std::endl; // <-- fails as overloaded
    return 0                     //     operator<< is not found
}

Compiling fails as overloaded operator<< is not found.

How to overload << operator of this non-type parameter template alias?

Aucun commentaire:

Enregistrer un commentaire