The description of the problem is quite easy... I have an enum placed inside a template class (which I prefer it to be) and for my application i need to be able to define the operator>>() function for this enum...
This however produces a problem in Visual Studio where the Microsoft C/C++ Optimizing Compiler stops working. In other words: "An internal error has occured in the compiler"
Example code which reproduces the error:
#include <iostream>
#include <stdexcept>
template <typename T>
struct S{
enum X { X_A, X_B, X_C };
template <typename U>
friend std::istream& operator>>(std::istream& in, enum S<U>::X& x);
};
template <typename U>
std::istream& operator>>(std::istream& in, enum S<U>::X& x)
{
int a;
in >> a;
x = S::X(a);
return in;
}
int main()
{
S<int> s;
S<int>::X x = S<int>::X_A;
std::cout << "Input: ";
std::cin >> x;
std::cout << "Output: " << x << std::endl;
}
Any help with solving this problem would be much appreciated! I would myself guess that because the class is templated the enum becomes defined multiple times somehow...