|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-02-19 12:03:40
Gabriel Dos Reis <gdr_at_[hidden]> writes:
> "Ken Hagan" <K.Hagan_at_[hidden]> writes:
>
> | Peter Dimov wrote:
> | >
> | > &k does not exist yet at compile-time (in a pointer to int form), when
> | > templates are instantiated.
> |
> | It doesn't have to. We're instantiating a template, not calling a
> | function, so if "&k" has the type "pointer to thread-local int" then
> | the compiler knows that and can instantiate the appropriate code.
>
> The issue here is the *value* "&k", not the type of that expression.
Let me reiterate, just in case somebody missed it: this is a similar
problem to that of using a pointer/reference-to-data-member as a
template paramter. You can think of each thread-local global variable
as a data member in a big struct, of which there's a single instance
per thread. The address of this global variable is just as much a
constant as the address of a data member. There's no problem here,
AFAICT.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk