fork download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. struct pseudo_void {};
  5.  
  6. template <typename T>
  7. struct N;
  8.  
  9. template <typename T>
  10. struct N<T()> {
  11. T operator()(T(&t)()) {
  12. return t();
  13. }
  14. };
  15.  
  16. template <typename T, typename ... F>
  17. struct N<T(F...)> {
  18. T operator()(T (&t)(F...), F &&... f) {
  19. return t(std::forward<F>(f)...);
  20. }
  21. };
  22.  
  23. template <typename ...F>
  24. struct N<void(F...)> {
  25. pseudo_void operator()(void (& t)(F...), F &&... f) {
  26. t(std::forward<F>(f)...);
  27. return pseudo_void();
  28. }
  29. };
  30.  
  31. template <>
  32. struct N<void()> {
  33. pseudo_void operator()(void (& t)()) {
  34. t();
  35. return pseudo_void();
  36. }
  37. };
  38.  
  39. std::ostream & operator<< (std::ostream & os, const pseudo_void &) {
  40. return os;
  41. }
  42.  
  43. void f(int) {}
  44.  
  45. int main() {
  46.  
  47. N<void(int)> n;
  48.  
  49. n(f, 4);
  50.  
  51. }
Success #stdin #stdout 0s 2924KB
stdin
Standard input is empty
stdout
Standard output is empty