return x;
}
- if (cxx_dialect >= cxx1z
- /* We deduce from array bounds in try_array_deduction. */
- && !(strict & UNIFY_ALLOW_INTEGER)
- && uses_template_parms (TREE_TYPE (parm))
- && !type_uses_auto (TREE_TYPE (parm)))
- {
- tree atype = TREE_TYPE (arg);
- RECUR_AND_CHECK_FAILURE (tparms, targs,
- TREE_TYPE (parm), atype,
- UNIFY_ALLOW_NONE, explain_p);
- }
-
/* [temp.deduct.type] If, in the declaration of a function template
with a non-type template-parameter, the non-type
template-parameter is used in an expression in the function
/* Template-parameter dependent expression. Just accept it for now.
It will later be processed in convert_template_argument. */
;
- else if (same_type_p (TREE_TYPE (arg), tparm))
+ else if (same_type_p (non_reference (TREE_TYPE (arg)),
+ non_reference (tparm)))
/* OK */;
else if ((strict & UNIFY_ALLOW_INTEGER)
&& CP_INTEGRAL_TYPE_P (tparm))
corresponding parameter. */
arg = fold (build_nop (tparm, arg));
else if (uses_template_parms (tparm))
- /* We haven't deduced the type of this parameter yet. Try again
- later. */
- return unify_success (explain_p);
+ {
+ /* We haven't deduced the type of this parameter yet. */
+ if (cxx_dialect >= cxx1z
+ /* We deduce from array bounds in try_array_deduction. */
+ && !(strict & UNIFY_ALLOW_INTEGER))
+ {
+ /* Deduce it from the non-type argument. */
+ tree atype = TREE_TYPE (arg);
+ RECUR_AND_CHECK_FAILURE (tparms, targs,
+ tparm, atype,
+ UNIFY_ALLOW_NONE, explain_p);
+ }
+ else
+ /* Try again later. */
+ return unify_success (explain_p);
+ }
else
return unify_type_mismatch (explain_p, tparm, TREE_TYPE (arg));
--- /dev/null
+// PR c++/81102
+
+template <typename FuncSig, FuncSig f>
+struct HelperWrapper;
+
+// [...]
+
+template <typename Ret, Ret (&Func)()>
+struct HelperWrapper<Ret (&)(), Func>
+{
+ static inline int WrapFuncT(const int)
+ {
+ return 0; // Changed
+ }
+};
+
+// Unary
+template <typename Ret, typename Arg1, Ret (&Func)(Arg1)>
+struct HelperWrapper<Ret (&)(Arg1), Func>
+{
+ static inline int WrapFuncT(const int)
+ {
+ return 1; // Changed
+ }
+};
+
+// Binary
+template <typename Ret, typename Arg1, typename Arg2, Ret (&Func)(Arg1, Arg2)>
+struct HelperWrapper<Ret (&)(Arg1, Arg2), Func>
+{
+ static inline int WrapFuncT(const int)
+ {
+ return 2; // Changed
+ }
+};
+
+int main()
+{
+ return 0;
+}