Is there a way to return an lvalue and also an rvalue from the same member function?

realhet real_het at hotmail.com
Sun Sep 20 17:08:49 UTC 2020


On Sunday, 20 September 2020 at 16:18:19 UTC, Steven 
Schveighoffer wrote:
> On 9/20/20 11:52 AM, realhet wrote:
>> On Sunday, 20 September 2020 at 14:54:09 UTC, Steven 
>> Schveighoffer wrote:
>>> On 9/20/20 9:30 AM, realhet wrote:
> Yeah, I think this might work.
>
> -Steve

That would be a 3rd category out if 4 in total:
- ref for the contiguous subVectors (vec4.init.yz is a vec2)
- const for the complicated ones (vec4.init.z0 is a vec2, 2nd 
component is 0)
- swizzled struct of a referenced vector: (vec4 a; a.yx is a 
struct that links to the original 'a' by reference and know it 
has to swap x and y).
- everything else that can contain any vector component at any 
place including constants 0 and 1. I've learned this kind of 
swizzling in the good old CAL/AMD_IL times.

Swizzled struct is on the righr: then it should be implicitly 
casted when assigning it to the left to a vector. I gotta learn 
that too.

In GLSL this behavior is implemented deeply in the compiler. I'm 
so happy in D it seems also possible :D


More information about the Digitalmars-d-learn mailing list