Quote:Original post by chidj
That shouldn't matter, the compiler is simply confused because the definition and implementation do not match.
I'm no template expert, but I believe it does matter in this case since the friend function is a template function. Using your suggestion implies that the function is a non-template function specialized for the specific instantiation of T. This would mean writing the function for each type that you use with v. My suggestion explicitly specifies that the function is a template function. Nevertheless, I believe that my suggestion also allows operator<< to access the private members of a v<double> even if it were instantiated with a v<int>. Like I said, I'm no template expert but feel free to enlighten me if I'm wrong. I'm always up for learning!
Anyways,
this GCC doc gives another possibility where you just simply use <> after the function name. This will prevent the issue I mentioned above. I don't know what the case may be for MSVS. Nevertheless, I'd suggest just going with theOcelot's advice to save yourself from possible future troubles.