fork download
  1. #include <iostream>
  2.  
  3. struct Plot{
  4. void add(double x, double y){
  5. std::cout << x << ' ' << y << '\n';
  6. }
  7. };
  8.  
  9. template <class UI_class, class... Args>
  10. auto wrapper(void (UI_class::*function)(Args...)) {
  11. return [function](UI_class &lui, Args &&... args) {
  12. #if 0
  13. [&lui, function, args = std::forward<Args>(args)... ]() mutable {
  14. (lui.*function)(std::move(args)...);
  15. }();
  16. #else
  17. (lui.*function)(std::forward<Args>(args)...);
  18. #endif
  19. };
  20. }
  21.  
  22. int main() {
  23. Plot p;
  24. auto function = wrapper(&Plot::add);
  25. function(p, 1, 2);
  26. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1 2