fork(1) download
  1. template<typename T1>
  2. struct Outer
  3. {
  4. void foo()
  5. {
  6. }
  7.  
  8. Outer() : inner( &Outer::foo ) // pass ptr member function
  9. {
  10. }
  11.  
  12. template<typename T2, void (T2::*F)()>
  13. struct Inner
  14. {
  15. Inner( F f ) // signature
  16. {
  17. }
  18. };
  19.  
  20. Inner<Outer,&Outer::foo> inner;
  21. };
  22.  
  23. int main()
  24. {
  25. Outer<int> outer;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:15:12: error: expected ‘)’ before ‘f’
   Inner( F f )    // signature
            ^
prog.cpp: In instantiation of ‘Outer<T1>::Outer() [with T1 = int]’:
prog.cpp:25:13:   required from here
prog.cpp:8:31: error: no matching function for call to ‘Outer<int>::Inner<Outer<int>, &Outer<int>::foo>::Inner(void (Outer<int>::*)())’
  Outer() : inner( &Outer::foo )  // pass ptr member function
                               ^
prog.cpp:8:31: note: candidates are:
prog.cpp:13:9: note: Outer<int>::Inner<Outer<int>, &Outer<int>::foo>::Inner()
  struct Inner
         ^
prog.cpp:13:9: note:   candidate expects 0 arguments, 1 provided
prog.cpp:13:9: note: Outer<int>::Inner<Outer<int>, &Outer<int>::foo>::Inner(const Outer<int>::Inner<Outer<int>, &Outer<int>::foo>&)
prog.cpp:13:9: note:   no known conversion for argument 1 from ‘void (Outer<int>::*)()’ to ‘const Outer<int>::Inner<Outer<int>, &Outer<int>::foo>&’
stdout
Standard output is empty