Using metaprogramming to shorten AutoDiff