another example is dynamic callbacks. You may carry around typeid of the function signature and a struct, containing parameter values for it, which also contains the typeid of it's target function's signature. If you don't impose type information on the typeless values, i will be able to check the types of the signatures (possibly by a hash value for efficiency) and i won't need to check the types of each parameter (since i'll be passing around array of typeless objects).
On Tue, Oct 25, 2011 at 7:33 PM, Robert Jacques <[email protected]> wrote: > On Tue, 25 Oct 2011 09:23:10 -0400, Gor Gyolchanyan > <[email protected]> wrote: >> >> I need an extremely fast and small typeless container for a single >> object, which i can use to implement a fast and efficient dynamic >> callback mechanism, where the exact number and types of parameters are >> only known to the callback and to the source of the parameter values >> and all intermediate manager classes, who hold and return the callback >> do not know it. >> >> On Tue, Oct 25, 2011 at 5:20 PM, Gor Gyolchanyan >> <[email protected]> wrote: >>> >>> Variant is heavy. It contains and does lots of things, that are not >>> always required. >>> a tiny type-less variable is versatile and can be used for any >>> purposes. It's even type-safe in debug mode. >>> Also, Variant needs explicit construction, whereas the tiny typeless >>> variable automatically accepts any value. >>> Also, Variant does not grant access to underlying raw data, but tiny >>> typeless value can be taken address of (void*). > > Just because something is feature-full, doesn't make it heavy weight. But I > guess over a raw tagged-union with a limited interface, it would be > considered heavy. But, I don't understand you concept of a type-less > variable. Truly type-less variables don't exist in any language; you always > have a pluripotent dynamic type like variant under the hood. >
