Christopher Wright wrote:
Andrei Alexandrescu wrote:
Christopher Wright wrote:
What information did you find that you needed but is not available in TypeInfo?

To have constant-type dispatching without limitations you need the static type information.

What do you mean by this? At first I thought you meant that TypeInfo does not contain sufficient information to determine whether something is const or immutable, but that is not the case. If you wish to convert a Variant of a mutable thing to a const version of it, then you can check whether the type you get is convertible, and without any trouble -- the template instantiation to get the appropriate type will provide the TypeInfo you need.

So what's the issue?

You may want to peruse the std.variant implementation. Variant is a struct containing a buffer for the data and a pointer to function. The function is a dispatcher for a handful of primitive operations.

The pointer to function is assigned from the address of a function template. To get that address, you need the static type. That's the necessity.

It's a very fast and very flexible design, but it does need the static type during initialization.


Andrei

Reply via email to