template inference for apply