Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/range-for20.C

raw
1 // PR c++/49834
2 // PR c++/50020
3 // { dg-do compile { target c++11 } }
4
5 struct A
6 {
7 template <typename T> T get_value() const;
8 };
9
10 struct B {
11 A first, second;
12 };
13
14 struct C
15 {
16 B* begin() const;
17 B* end() const;
18 };
19
20 template <typename Ret>
21 struct D
22 {
23 Ret f(const C &p)
24 {
25 for (const B &i: p) // OK
26 i.second.get_value<int>();
27 for (const auto &i: p) // ERROR
28 i.second.get_value<int>();
29 return Ret(0);
30 }
31 };
32
33 void g()
34 {
35 D<int>().f(C());
36 }