Jonathan M Davis <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #4 from Jonathan M Davis <> 2012-08-08 10:11:34 
PDT ---
> I could understand if the opBinaryRight template wasn't constrained to "in",
but it is, so I see no reason why it cannot be in the vtable since it can only
ever have one instance in a class.

Because templated functions _never_ end up in the vtable. Mixed in templates
may if they're fully instantiated when mixed in (I don't remember), but a
templated function written directly in the class is _never_ virtual.

That doesn't necessarily mean that there are no situations where the language
could be enhanced to make a templated function virtual if it's actually
restricted enough (and this may be such a case), but as it stands, being a
template is enough to make it non-virtual regardless of what it does or how
constrained it is or isn't. I don't believe that even

int func()() { return 2; }

would be virtual, and that's pretty much as constrained as it gets.

Of course, if such a function _did_ get changed to virtual, then it would
always defined, whereas right now it's only defined if used, which could be a
definite negative, depending on the programmer's intent. So, there's defintely
a tradeoff here even if it's possible to make some templated functions virtual.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to