re PR c++/64227 (Forwarding an argument of a function template to a generic lambda...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 4 Mar 2015 10:20:23 +0000 (10:20 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 4 Mar 2015 10:20:23 +0000 (10:20 +0000)
2015-03-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/64227
* g++.dg/cpp1y/lambda-generic-ice1.C: New.

From-SVN: r221181

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

index a2dadbf972638ed0b11082af57e5cf57894f084c..f3e7f882b90592e59d11db96e2138a3f03c7de7a 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/64227
+       * g++.dg/cpp1y/lambda-generic-ice1.C: New.
+
 2015-03-04  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * gcc.target/aarch64/atomic-comp-swap-release-acquire.c: Add
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice1.C
new file mode 100644 (file)
index 0000000..0e40e62
--- /dev/null
@@ -0,0 +1,42 @@
+// PR c++/64227
+// { dg-do compile { target c++14 } }
+
+template<typename T>
+struct remove_reference
+{ typedef T   type; };
+
+template<typename T>
+struct remove_reference<T&>
+{ typedef T   type; };
+
+template<typename T>
+struct remove_reference<T&&>
+{ typedef T   type; };
+
+template<typename T>
+constexpr T&&
+forward(typename remove_reference<T>::type& t) noexcept
+{ return static_cast<T&&>(t); }
+
+template<typename T>
+constexpr T&&
+forward(typename remove_reference<T>::type&& t) noexcept
+{ return static_cast<T&&>(t); }
+
+template<typename T>
+auto greater_than(T&& t)
+{
+  return [val = forward<T&&>(t)] (const auto& arg) { return arg > val; };
+}
+
+template<typename Functor>
+void g(Functor f)
+{
+  for (int i = 0; i < 100000; i++)
+    f(i);
+}
+
+int main()
+{
+  g(greater_than(10));
+}