Possible to Create Functions Dynamically
I want to know is it possible to create functions dynamically, such as inside dynamic memory blocks using pointers and possibly with templates? The function would not have been written beforehand which is why I thought templates might do the trick since they are created when needed.
The point of this is to have functions in memory and freed from memory when not needed anymore instead of hard coded into the executable. I'm not referencing a pointer to a function, but more along the lines of a pointer to a dynamic memory block with a function inside of it.
Re: Possible to Create Functions Dynamically
I don't understand (a) what benefit this would have, or (b) how you'd expect to define a function to do something useful using only runtime operations.
Second, templates are instantiated at compile time, so you definitely can't do anything with them at runtime. However, you can do some interesting compile-time tricks with them which resemble runtime programming; see the Boost Metaprogramming Library (MPL) for some examples.