The comma operator can be overloaded, although it is usually not recommended (in many cases, an overloaded comma is confusing).
The above expression defines 16 values ββfor a 4 * 4 matrix. If you're curious about how this is possible, I'll show you a simpler example. Suppose we want to write something like
MyVector<double> R = (MyVector<double>() << 1 , 2 , 3);
then we can define MyVector so that the << and , operators add a new value to the vector:
template<typename T> class MyVector: public std::vector<T> { public: MyVector<T>& operator << (T value) { push_back(value); return *this; } MyVector<T>& operator , (T value) { push_back(value); return *this; } ... };
source share