fork download
  1. #include <iostream>
  2.  
  3. template < typename T > struct A
  4. {
  5. template< void (*FN) (T) > static void call( T arg ) { FN(arg) ; }
  6.  
  7. static void call( void (*fn)(T), T arg ) { fn(arg) ; }
  8. };
  9.  
  10. void foo( int a ) { std::cout << "foo(" << a << ")\n" ; }
  11.  
  12. int main()
  13. {
  14. A<int>::call<foo>(1) ;
  15.  
  16. A<int>::call( foo, 2 ) ;
  17. }
  18.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
foo(1)
foo(2)