[PATCH] Consolidate and unify initializer list deduction

Richard Smith richard at metafoo.co.uk
Wed Jun 24 12:25:22 PDT 2015


================
Comment at: lib/Sema/SemaTemplateDeduction.cpp:3201
@@ +3200,3 @@
+static bool
+DeduceFromInitializerList(Sema &S, TemplateParameterList *TemplateParams,
+                          QualType AdjustedParamType, InitListExpr *ILE,
----------------
Maybe just make this return the `TemplateDeductionResult`? You -- almost, see below -- always treat a return of `false` from here and a return of `true` with `Result == TDK_Success` the same (which makes sense, because they mean the same thing -- deduction succeeded).

================
Comment at: lib/Sema/SemaTemplateDeduction.cpp:3432-3433
@@ -3411,3 +3431,4 @@
+                                       Info, Deduced, TDF, Result)) {
           ++ArgIdx;
           break;
         }
----------------
Is this really right? It seems to cause an accepts-invalid on this:

    #include <initializer_list>
    #include <tuple>
    template<typename ...T> void f(std::tuple<T...> a, T ...b);
    void g() { f(std::make_tuple(1, 2), {}, 3.0); }

Should this instead be ignoring this P/A pair and carrying on to the next, as we do if deduction succeeds? (This is a pre-existing bug, but it's the only barrier to the cleanup I suggested above.)

http://reviews.llvm.org/D10681

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list