Implements auto ref for non-template function which generates temporary variables.