mercredi 11 octobre 2017

Instantiating identifier with dynamic type info on standard types

I know it is possible to deduce the parameter a function receives with

const char* x = typeinfo(parameter).name;
// returns const char* 'm' on my machine

Is it possible, if a function receives a generic parameter, to also instantiate a new object of the same type. Something like:

<x> foo;

I see here: Creating a new object from dynamic type info that it isn't possible for objects, but I am wondering if it is possible for internal types like int.

Thanks!

Aucun commentaire:

Enregistrer un commentaire