I have the following header file, tag T
is a struct, don't worry about it
template <tag T>
class index_class {
public:
index_class();
index_class(const index_class& other);
explicit index_class(index_carrier_type<T> value);
index_class& operator=(const index_class& other);
index_carrier_type<T> value() const;
bool operator==(index_class& other);
bool operator!=(index_class& other);
friend std::ostream & operator<<(std::ostream& os, const index_class& idx);
private:
index_carrier_type<T> value_;
};
And in the .cpp file I have the following:
#include "tagged_vector.hpp"
template <tag T>
std::ostream& index_class<T>::operator<<(std::ostream& os, const index_class& idx) {
if (idx.value_ == std::numeric_limits<index_carrier_type<T>>::max()) {
throw std::range_error("Uninitialized index");
}
os << idx.value_;
return os;
}
Yet I get an error. I have e problem with the friend operator<<, but I don't know what. I am using c++20.
I tried to remove the friend
keyword.