On 10/20/06, Arnaldur Gylfason <arnaldur.gylfason@decode.is> wrote:
>I think you are trying to achieve an impossible
thing. Compiler is the one
>to
>create the types. You can control the compiler, so that it creates
the
>types
>based on a non-trivial algorithm, but all of this should be done at
compile
>time,
>and based on compile-time input: types and constants hardcoded into
your
>program.
>By the runtime it's over -- you can't create the types based on the
runtime
>string value.
>The typeof solves the problem because it works at compile time.
Yes I have come to the same conclusion. Thanks for
your response.
Some kind of eval would come in handy. Dynamic typing
as in Python would also be a blessing here.
Of course it would be possible to solve this by calling
Python but it would be an expensive function call!
If C++ had dynamic typing and eval, etc, it would probably be an expensive call as well. It doesn't come for free.
cheers
Arnaldur