Template madness - template operator not found

Started by
10 comments, last by Zlodo 8 years ago

I remember having issues with templates when I built my own lib.

I don't remember all details, but I do remember that it required to write specific templates to support them.

(For classes I needed to do "template class Myclass<int>"). I guess it's almost the same with methods. Issues with getting the concrete types so you need to speficy it.

Advertisement

Move your + operator into A as a friend function and it works:


typedef std::size_t Size;
 
template < typename T >
class A
{
	public:
 
		template < Size x >
		class B
		{
			T asdf[x];
		};
 
                template <Size x >
                friend A operator + ( T value, const B<x>& vec )
                {
        	        return A();
                }	
};
 
int main( int argc, char** argv )
{
	A<float>::B<2> b;
	5.0f + b; // Works
}

This topic is closed to new replies.

Advertisement