3 ms·
I'm curious, would C++ ever consider categories like in ObjC? I.e. class extensions that unlike inheritance don't change the type. It kind of gets close with t
by mojuba 11y ago
I'm curious, would C++ ever consider categories like in ObjC? I.e. class extensions that unlike inheritance don't change the type.
It kind of gets close with the unified call: if you have a call f(x,y) then either x.f(y) is matched or some f(x,y) that may be defined elsewhere. But still not the same as the ability to define a new x.g(y) for an existing class.
(Edit: I can't even start to think what implications this will have on templates. They will probably become even more impenetrable.)
- mikeash 11y agoTheir proposal to allow x.f(y) to match a free function f(x, y) would obviate the need for anything like categories. I'm puzzled and saddened that this part of the proposal didn't go through.
- deleted 11y ago[deleted]