__has_side_effects

Uknown sireeshkodali1 at gmail.com
Sun Apr 1 04:11:37 UTC 2018


On Friday, 30 March 2018 at 20:28:27 UTC, Andrei Alexandrescu 
wrote:
> https://www.reddit.com/r/programming/comments/88aqsf/the_joy_of_max/
>
> Discussion aside, I notice with pleasant surprise gcc has an 
> introspection primitive we didn't think of: __is_constant that 
> (I assume) yields true if the given expression has no side 
> effects.
>
> In D the primitive would be called e.g. __has_side_effects to 
> avoid confusion with the "const" qualifier.
>
> I wonder how difficult it would be to define __has_side_effects 
> (it would apply to an alias) and how it can be put to good use.
>
>
> Andrei

Just for the fun of it, I implemented this as a template:

https://run.dlang.io/is/pXLndG


More information about the Digitalmars-d mailing list