[D1] struct opEquals questions

qwerty qw at er.ty
Thu Mar 18 09:30:59 PDT 2010


bearophile Wrote:

> qwerty:
> > If I return *this, I should also provide the *S version of opEquals? 
> 
> If you don't provide a necessary operator the compiler complaints.
> 
> 
> > What happens with the return value if it isn't used?
> 
> The function is one and it doesn't change, it has to be the same for everyone that calls it (time ago I have suggested for a compile time flag that's defined inside functions to know if their result is used, to avoid computing it in some situations, turning the single function in a kind of templated function, but I am not sure it can work well if you have function pointers. So you need a single entry point for two functions).

For a function without any side effects, it shouldn't be a problem.. I think :)

> 
> 
> > I mean, where will the *this end up? Or will the compiler not return it at all?
> 
> The function returns it, but the result is ignored. In such situations reading a little the asm helps.

Yet another thing I should learn.. asm :)

> 
> Bye,
> bearophile



More information about the Digitalmars-d-learn mailing list