From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-02-19 10:13:22
Ken Hagan wrote:
> 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.
Indeed it can, and it (MSVC 7.1b) even does. I stand corrected.
typedef boost::detail::lightweight_mutex mutex_type;
template<uintptr_t * p> struct C
std::cout << " p: " << p << ": " << *p << std::endl;
__declspec(thread) uintptr_t k = 0;
unsigned __stdcall f(void * pt)
k = *(uintptr_t *)pt;
std::cout << "&k: " << &k << ": " << k << std::endl;
uintptr_t t1 = _beginthreadex(0, 0, f, &t1, 0, 0);
uintptr_t t2 = _beginthreadex(0, 0, f, &t2, 0, 0);
uintptr_t t3 = _beginthreadex(0, 0, f, &t3, 0, 0);
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk