September 06, 2017 pure void* memset(return void* s, int c, size_t n)? | ||||
---|---|---|---|---|
| ||||
What is the return doing there? |
September 06, 2017 Re: pure void* memset(return void* s, int c, size_t n)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Psychological Cleanup | On Wednesday, 6 September 2017 at 06:09:46 UTC, Psychological Cleanup wrote:
> What is the return doing there?
The return implies that the function will return the parameter `s` after it has done whatever it needs to.
It is useful for the compiler to do escape analysis or
So memset would be something like this:
pure void * memset(return void * s, int c, size_t n)
{
foreach (i; 0 .. n)
(cast(char *) s)[i] = cast(char) c;
return s;
}
|
Copyright © 1999-2021 by the D Language Foundation