I fail to understand the reason why the code below does not compile. Live.
Thank you.
#include <iostream>
#include <iterator>
#include <sstream>
using namespace std;
namespace N
{
class C
{
public: enum class E { a, b, c };
};
}
using U = N::C::E;
istream& operator>>( istream& is, U& e )
{
//...
return is;
}
int main()
{
istringstream ss{ "0 1 2" };
U e;
ss >> e; // fine
istream_iterator<U> ii( ss ); // binary '>>': no operator found which takes a right-hand operand of type '_Ty' (or there is no acceptable conversion)
}