[eval] Remove template param from TransformBinaryDifferingArityElements

All of the callers use the same signature for the lambda function. This
CL defines an `BinaryTransfrom` std::function which is used instead of
the template parameter.

There are 65 separate copies of this function in the current chrome canary. One for each template usage. Each of those copies takes .25kb of space in the binary for a total of ~16k.

Change-Id: Ifeebe3710f119ab395290fed7906a520c87815f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/148280
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/core/constant/eval.cc b/src/tint/lang/core/constant/eval.cc
index be86578..f51ea35 100644
--- a/src/tint/lang/core/constant/eval.cc
+++ b/src/tint/lang/core/constant/eval.cc
@@ -467,7 +467,7 @@
 template <typename F, typename... CONSTANTS>
 Eval::Result TransformElements(Manager& mgr,
                                const core::type::Type* composite_ty,
-                               F&& f,
+                               const F& f,
                                size_t index,
                                CONSTANTS&&... cs) {
     auto [el_ty, n] = First(cs...)->Type()->Elements();
@@ -506,19 +506,21 @@
 template <typename F, typename... CONSTANTS>
 Eval::Result TransformElements(Manager& mgr,
                                const core::type::Type* composite_ty,
-                               F&& f,
+                               const F& f,
                                CONSTANTS&&... cs) {
     return detail::TransformElements(mgr, composite_ty, f, 0, cs...);
 }
 
+/// Signature of a binary transformation callback.
+using BinaryTransform = std::function<Eval::Result(const Value*, const Value*)>;
+
 /// TransformBinaryDifferingArityElements constructs a new constant of type `composite_ty` by
 /// applying the transformation function 'f' on each of the most deeply nested elements of both `c0`
 /// and `c1`. Unlike TransformElements, this function handles the constants being of different
 /// arity, e.g. vector-scalar, scalar-vector.
-template <typename F>
 Eval::Result TransformBinaryDifferingArityElements(Manager& mgr,
                                                    const core::type::Type* composite_ty,
-                                                   F&& f,
+                                                   const BinaryTransform& f,
                                                    const Value* c0,
                                                    const Value* c1) {
     uint32_t n0 = c0->Type()->Elements(nullptr, 1).count;