| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-std=c++0x" } |
| 3 |
|
| 4 |
struct Iter |
| 5 |
{ |
| 6 |
int& operator* (); |
| 7 |
void operator++ (); |
| 8 |
}; |
| 9 |
|
| 10 |
bool operator!= (Iter &, Iter &) { return true; } |
| 11 |
|
| 12 |
struct Container |
| 13 |
{ |
| 14 |
Iter begin () const; |
| 15 |
Iter end () const; |
| 16 |
}; |
| 17 |
|
| 18 |
struct J |
| 19 |
{ |
| 20 |
virtual J *mutable_child (); |
| 21 |
}; |
| 22 |
|
| 23 |
struct M |
| 24 |
{ |
| 25 |
M (const Container &); |
| 26 |
J ns_; |
| 27 |
}; |
| 28 |
namespace |
| 29 |
{ |
| 30 |
J MakeNamespace (const Container &src) |
| 31 |
{ |
| 32 |
J a; |
| 33 |
J *b = 0; |
| 34 |
for (const int &c: src) |
| 35 |
b = b ? b->mutable_child () : &a; |
| 36 |
return a; |
| 37 |
} |
| 38 |
} |
| 39 |
M::M (const Container &ns):ns_ (MakeNamespace (ns)) |
| 40 |
{ |
| 41 |
} |