ea**********@h1g2000prh.googlegroups.com>, sm*****@gmail.com says...
Hello!One possibility would be like this:
I would like to have an output streaming operator for an enum that is
inside a templated class, but I just can't seem to make it work! I
suspect that I have a template ambiguity issue, but I haven't pinned
down what change will make the code work.
The following example illustrates the problem. I would like the
program to print 'C', but it prints '2'.
#include <iostream>
template <typename F>
struct M {
enum Ts {A, B, C};
class T {
typename M::Ts t;
public:
T(typename M::Ts val) : t(val) {}
friend std::ostream &operator<<(
std::ostream &os,
typename M<F>::T const &m)
{
static char const names[] = "ABC";
return os << names[m.t];
}
};
};
int main()
{
M<float>::T t = M<float>::C;
std::cout << "t = " << t << std::endl;
}
--
Later,
Jerry.
The universe is a figment of its own imagination.