Dynamic templated virtuals - I still often want them
Adam D. Ruppe
destructionator at gmail.com
Thu Jul 23 17:05:02 UTC 2020
On Thursday, 23 July 2020 at 15:00:59 UTC, Max Samukha wrote:
> FWIW, a more general way to initialize an object with static
> type data would be (currently it fails for indirectly derived
> classes due to a compiler bug):
Yeah, I've tried that in the past too, it has a couple
limitations (even if it worked):
1) it would only run at the construction site, meaning it must
actually store data with the instance instead of just returning a
new data in a method. This could be as simple as storing a
pointer to some static data in the instance but it must be
something.
2) it might not go all the way down. Imagine:
class Grandchild : Derived {}
there the implicit constructor for Derived would be called that
can satisfy Base... but Grandchild may not be seen. Of course the
compiler could require an explicit call to the (this This) one
too though.
> Also, there seems to be no good reason "this T" should not work
> for any class member, including class static constructors.
indeed.
More information about the Digitalmars-d
mailing list