Address of return value.

Artur Skawina art.08.09 at gmail.com
Tue Dec 11 14:43:07 PST 2012


On 12/11/12 22:05, monarch_dodra wrote:
> On Tuesday, 11 December 2012 at 21:00:11 UTC, Timon Gehr wrote:
>> On 12/11/2012 05:58 PM, monarch_dodra wrote:
>>> On Tuesday, 11 December 2012 at 16:45:54 UTC, cal wrote:
>>>> On Tuesday, 11 December 2012 at 15:38:38 UTC, monarch_dodra wrote:
>>>>> On Tuesday, 11 December 2012 at 14:57:27 UTC, monarch_dodra wrote:
>>>>>> :/
>>>>>
>>>>> I got it to work with a cast, which removes the ambiguity:
>>>>>
>>>>> auto p = &cast(int)s.front;
>>
>> This might be be an accepts-invalid. I think it is undocumented.
>>
>>>>>
>>>>> But it feels hackish. Any other way?
>>>>
>>>> auto p = &(s.front());
>>>>
>>>> Not sure if this is intended though, maybe some property weirdness?
>>>
>>> Strange, I was *sure* I had tried that.
>>>
>>> Oh, well. Thanks :)
>>
>> This will break, you call an @property function with ().
>>
>> But I don't think it is decided yet how what you want to achieve should be done. :o)
> 
> So... basically, I have two solutions which are both accepts-invalid !?

   auto addrOf(T)(ref T a) { return &a; }

   auto p = addrOf(s.front);

artur


More information about the Digitalmars-d-learn mailing list