compile time 'address'
Dominic Jones
dominic.jones at gmx.co.uk
Thu Nov 29 22:14:58 UTC 2018
On Thursday, 29 November 2018 at 21:00:57 UTC, Stanislav Blinov
wrote:
>> There's no way to accept a pointer that can't be used, just
>> the value of the pointer checked.
>
> Yeah, but this one seems a bit deliberate. The asserts hold,
> but you can't e.g.
>
> enum diff = &c0 - &c1; // 'c0' can't be used at compile time
This is the same situation as C++; the addresses can only be
compared (with == or !=). Any attempt to capture their values
first will cause a compilation failure, i.e. attempting:
// "error: '& t' is not a constant expression", etc
auto constexpr ta = &t;
auto constexpr ua = &u;
return ta == ua;
More information about the Digitalmars-d
mailing list