]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/range-for11.C
PR c++/92590 - wrong handling of inherited default ctor.
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / range-for11.C
CommitLineData
deb9642d
JM
1// Test for range-based for loop
2// Test the loop with a custom iterator
3// with begin/end as member functions
4
4b2e63de 5// { dg-do compile { target c++11 } }
deb9642d
JM
6
7struct iterator
8{
9 int x;
10 explicit iterator(int v) :x(v) {}
11 iterator &operator ++() { ++x; return *this; }
12 int operator *() { return x; }
13 bool operator != (const iterator &o) { return x != o.x; }
14};
15
16namespace foo
17{
18 struct container
19 {
20 int min, max;
21 container(int a, int b) :min(a), max(b) {}
22
23 iterator begin()
24 {
25 return iterator(min);
26 }
27 iterator end()
28 {
29 return iterator(max + 1);
30 }
31 };
32}
33
34int main()
35{
36 foo::container c(1,4);
37 for (int it : c)
38 ;
39}
This page took 5.573066 seconds and 5 git commands to generate.