re PR c++/68388 (incomplete type bug when using decltype)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 24 Nov 2015 18:16:26 +0000 (18:16 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 24 Nov 2015 18:16:26 +0000 (18:16 +0000)
2015-11-24  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/68388
* g++.dg/cpp1y/pr68388.C: New.

From-SVN: r230827

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr68388.C [new file with mode: 0644]

index 5fcb76941b0022e30d9d22a02b678f82b37ddd24..ab038201b2b1106d60549ba48b432139a9b6f54d 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/68388
+       * g++.dg/cpp1y/pr68388.C: New.
+
 2015-11-24  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr68388.C b/gcc/testsuite/g++.dg/cpp1y/pr68388.C
new file mode 100644 (file)
index 0000000..f1a342a
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-do compile { target c++14 } }
+
+namespace std {
+typedef int size_t;
+template <std::size_t... Indexes>
+struct index_sequence {};
+}
+
+template <class...> class Tuple {};
+
+template <std::size_t I, class TFirst>
+auto get(Tuple<TFirst>) {
+  return TFirst();
+}
+
+template <std::size_t I, class Functor, class T1, class T2>
+auto apply_impl(Functor f, T1 t1, T2 t2) {
+  return f(get<I>(t1), get<I>(t2));
+}
+
+template <std::size_t... Indexes, class Functor, class T1, class T2>        
+auto map_impl(std::index_sequence<Indexes...>, Functor f, T1 t1, T2 t2) {
+  Tuple<decltype(apply_impl<Indexes>(f, t1, t2))...>();
+}
+
+template <class Functor, class T1, class T2>
+auto map_impl(Functor f, T1 t1, T2 t2) {
+  map_impl(std::index_sequence<0>(), f, t1, t2);
+}
+                                 
+struct Less {                                                
+  template <class Lhs, class Rhs>                     
+  auto operator()(Lhs lhs, Rhs rhs) -> decltype(lhs < rhs) {
+    return lhs < rhs;
+  }
+};
+                                                                     
+int main() {
+  auto t1 = Tuple<int>();
+  auto t2 = Tuple<int>();
+  map_impl(Less(), t1, t2);
+}