PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / pr70098.C
blobc7b4f63ef844c821ff38883b44a8cca386ae62ff
1 // PR target/70098
2 // { dg-do compile }
3 // { dg-options -O2 }
4 // { dg-require-effective-target c++11 }
6 template < typename > struct traits;
7 template < typename, int _Rows, int _Cols, int = 0, int = _Rows,
8         int = _Cols > class Matrix;
9 template < typename > class G;
10 template < typename Derived > struct A {
11         typedef G < Derived > type;
14 template < typename Derived > class C {
15 public:
16         enum { RowsAtCompileTime =
17                     traits < Derived >::RowsAtCompileTime } static Zero;
20 template < typename Derived > class G:public C < Derived > {
23 template < int _Rows > class D {
24 public:
25         long rows() {
26                 return _Rows;
27         }
30 template < typename Derived > class PlainObjectBase:public A < Derived >::type {
31         typedef typename A < Derived >::type Base;
32         D < Base::RowsAtCompileTime > m_storage;
34 public:
35         long rows() {
36                 return m_storage.rows();
37         }
40 int fn1();
42 struct B {
43         static long run(long x, long) {
44                 int offset(fn1());
45                  return x + offset;
46 }};
48 long fn2(int x)
50         return B::run(x, 0);
53 template < typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows,
54     int _MaxCols >
55     struct traits <Matrix < _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols >> {
56         enum { RowsAtCompileTime = _Rows };
59 template < typename, int, int, int, int _MaxRows, int _MaxCols >
60         class Matrix:public PlainObjectBase < Matrix < double, _MaxRows,
61         _MaxCols >> {
62 public:
63         template < typename OtherDerived > Matrix(OtherDerived);
66 struct F {
67         static Matrix < double, 2, 2 > run(long size) {
68                 Matrix < double, 2, 2 > diag = Matrix < double, 2, 2 >::Zero;
69                 long i = 0;
70                 while (i < size) {
71                         long randomInt = fn2(-1);
72                         if (randomInt == 0)
73                                 ++i;
74                         else {
75                                 double alpha(randomInt);
76                                  diag = alpha;
77                                  i = 2;
78                         }
79                 }
81                 return diag;
82         }
85 void fn3(Matrix < double, 2, 2 > m)
87         long size = m.rows();
88         F::run(size);