|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-02-18 15:13:35
Greg Colvin wrote:
> Any thoughts on this issue?
>
>> From: Steve Clamage <stephen.clamage_at_[hidden]>
>> To: C++ core language mailing list
>> Message c++std-core-9820
>>
>> Some compilers implement thread-local storage (TLS) for what would
>> otherwise be global variables. The compiler and runtime system
>> arrange for each thread to see its own copy of a global variable.
>>
>> Should the address of such a variable be allowed as a non-type
>> template parameter? For example, this code is OK:
>> extern int k;
>> template< int* V > class C { ... };
>> C<&k> ck;
>>
>> But what if k is designated thread-local? The actual variable
>> referred to by the address of k will differ among threads.
Looks like a no-brainer, &k can't be a compile-time constant if k is
thread-local.
1.
void f()
{
C<&k> ck;
}
2.
void f()
{
typedef C<&k> ck_type;
ck_type ck;
}
3.
typedef C<&k> ck_type;
void f()
{
ck_type ck;
}
The type of ck cannot depend on the thread that is executing f.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk