Just throwing an idea out there... How about using annotations to teach the compiler which functions are inverses of each-other, in order to facilitate optimizing away certain redundant operations even if they are located inside a library(i.e. no source).

A little pseudo-code for illustrational purposes, in case my above text is incomprehensible:

void inc() pure nothrow @inverse(dec)
void dec() pure nothrow @inverse(inc)

void swap(T)(ref T lhs, ref T rhs) pure nothrow @inverse(swap!T)

Reply via email to