From: Marco Costalba (mcostalba_at_[hidden])
Date: 2007-11-02 09:03:53
On 11/2/07, Dean Michael Berris <mikhailberis_at_[hidden]> wrote:
> On 11/2/07, gchen <chengang31_at_[hidden]> wrote:
> That is because you need to know what signatures the overload instance
> will support. In C++, you have no way of modifying a type at runtime
> -- and that's why what you propose is nearly impossible if not
> impractical to implement.
I would say it's impossible in C++ ;-)
I stumbled on this during my little object factory development. The
reason it is impossible is that templates do not change the type of
already defined variables.
In your example:
// after compiler processes the above statement the type of 'f' has
//defined, 'f' is no more a template after compilation of this line!
so type of 'f'
// cannot be changed again but...
// ...it should be because the above line would change the type of 'f'
as soon as
// compiler process the above statement.
So the reason the above is impossible is that:
- After compilation of a template variable definition, the variable
assumes a fixed, complete type.
- In C++ type of a variable cannot be changed once the variable has
Hope this is clear.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk