1// PR c++/49663 2 3struct Nosm 4{ 5 int m_R; 6}; 7 8namespace dx { 9 10 struct onc 11 { 12 typedef void(*Cb)(); 13 14 onc(Cb cb); 15 }; 16 17 struct grac 18 { 19 template<class Derived> static void once(); 20 }; 21 22 template<class Derived> 23 struct tonc : onc 24 { 25 tonc() : onc(&grac::once<Derived>) {} 26 27 static Derived& get(); 28 }; 29 30 template<class Derived> void grac::once() 31 { 32 tonc<Derived>::get().h(); 33 } 34} 35 36namespace 37{ 38 template<typename T, int = sizeof(&T::m_R)> 39 struct has_R { }; 40 41 template<typename T> 42 inline void 43 setR(T* m, has_R<T>* = 0) 44 { } 45 46 inline void setR(...) { } 47} 48 49template<typename M> 50 struct Qmi 51 : dx::tonc<Qmi<M> > 52 { 53 void h() 54 { 55 setR(&msg); 56 } 57 58 M msg; 59 }; 60 61Qmi<Nosm> x; 62