1 // PR c++/51547 2 // { dg-do compile { target c++11 } } 3 4 template <class T> 5 struct vector 6 { 7 T* beginvector8 begin() 9 { return &member; } 10 11 const T* beginvector12 begin() const 13 { return &member; } 14 15 T member; 16 }; 17 18 struct Bar { 19 int x; 20 }; 21 22 struct Foo { barFoo23 const vector<Bar>& bar() const { 24 return bar_; 25 } 26 27 vector<Bar> bar_; 28 }; 29 30 template <class X> 31 struct Y { fooY32 void foo() { 33 Foo a; 34 auto b = a.bar().begin(); 35 auto&& c = b->x; 36 } 37 }; 38 39 template <class X> foo()40void foo() { 41 Foo a; 42 auto b = a.bar().begin(); 43 auto&& c = b->x; 44 } 45 main()46int main() { 47 Y<int> p; 48 p.foo(); 49 foo<int>(); 50 } 51