Presumably get_status returns a fooStatus
by value, which can't be bound to a mutable reference in the signature of operator<<
. You need to change fooStatus&
to const fooStatus&
in your overload of operator<<
, which will bind correctly.
#include <iostream>
enum fooStatus
{
DOWN = 0,
TEMPORARY_DOWN = 1,
UP = 2
};
template<
typename CH,
typename TRAITS
>
inline std::basic_ostream<CH, TRAITS>& operator<<(
std::basic_ostream<CH, TRAITS>& os,
const fooStatus& status
)
{
switch (status)
{
case DOWN:
os << "DOWN";
break;
case TEMPORARY_DOWN:
os << "TEMPORARY_DOWN";
break;
case UP:
os << "UP";
break;
default:
os << "UNKNOWN STATUS";
break;
}
return os;
}
int main()
{
std::cout << TEMPORARY_DOWN;
return 0;
}