While being a very modest piece of code in and of itself, I believe this offers a significant opportunity that both D compilers and user defined types can exploit.

I did this in C/C++ a while ago, out of which I have forgotten most of it :)

https://github.com/nordlow/justcxx/blob/master/sadd.h
https://github.com/nordlow/justcxx/blob/master/ssub.h
https://github.com/nordlow/justcxx/blob/master/smul.h

Tests are here:
https://github.com/nordlow/justcxx/blob/master/t_ranged_and_saturated.cpp

Maybe there's something more here that could give further ideas.

Pick what you want.

Reply via email to