As an addition, I didn't realize C++0x support was still so buggy. I've already had one segmentation fault (for something like this):
And once I hack-fixed it to something very ugly:
template<int S, typename T1, typename T2>
auto operator+(const A<S, T1> &first, const A<S, T1> &second) -> A<S, decltype(first.f1() + first.f2())>
It did work, however at that point the following would no longer work:
template<int S, typename T1, typename T2, typename R = decltype(*(T1*)0 + *(T2*)0)>
A<S, R> operator+(const A<S, T1> &first, const A<S, T1> &second)
As it would write a pointer value to the stream, rather than calling the operator<< I implemented for the stream.
std::cout << (a_instance1 + a_instance2) << std::endl;
Right. C++0x support. Is. Not. Good.
EDIT: (again) Well, okay, the last bit was my fault for not making the stream operator<< allow const references but only non-const. Damnit.