re PR c++/65949 (Compiler can not deduce auto type in lambda)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 30 Sep 2017 20:42:05 +0000 (20:42 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 30 Sep 2017 20:42:05 +0000 (20:42 +0000)
2017-09-30  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/65949
* g++.dg/cpp1y/lambda-generic-variadic5.C: New.

From-SVN: r253322

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic5.C [new file with mode: 0644]

index cd4688e7916fbf537c6e78726c6371605a8167c9..fcf901a6a4d33920e27d6ee13b256af4532565f1 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/65949
+       * g++.dg/cpp1y/lambda-generic-variadic5.C: New.
+
 2017-09-30  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/68754
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic5.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic5.C
new file mode 100644 (file)
index 0000000..6dbb9c8
--- /dev/null
@@ -0,0 +1,61 @@
+// PR c++/65949
+// { dg-do compile { target c++14 } }
+
+#include <initializer_list>
+
+template<class T, class... Ts>
+struct Over : T, Over<Ts...>::type
+{
+    using type = Over;
+
+    Over(T f1, Ts... f2)
+        : T(f1), Over<Ts...>::type(f2...)
+    {
+    }
+
+    using T::operator();
+    using Over<Ts...>::type::operator();
+};
+
+template<class T>
+struct Over<T> : T
+{
+    using type = T;
+    using T::operator();
+};
+
+template <class... Lambdas>
+auto CreateLambdas(Lambdas... lambdas)
+{
+    return Over<Lambdas...>(lambdas...);
+}
+
+int main()
+{
+    auto mesLambda = CreateLambdas
+    (
+        []()
+        {
+
+        },
+
+        [](auto i)
+        {
+         (void)i;
+        },
+
+        [](auto... args)
+        {
+            auto list = {args...};
+
+            for(auto &&a : list)
+             (void)a;
+
+            return 3;
+        }
+    );
+
+    mesLambda();
+    mesLambda(1);
+    mesLambda(12,24,36,48);
+}