with the following code (a boiled-down version of my original code)
#include
#include
template class A;
Your function auto diff(A access the private variable A::a from outside the class in your decltype statement.
Your A::a should be public if you want to use it the way you do in your diff function.
EDIT: it seems the friendship solution is much better suited for this problem, then just making it public.